Difference between revisions of "Simple Computer Simulator Instruction-Set"
(→Memory Instructions) |
|||
Line 1: | Line 1: | ||
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 16:57, 26 August 2014 (EDT) | --[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 16:57, 26 August 2014 (EDT) | ||
---- | ---- | ||
− | + | __TOC__ | |
+ | <br /> | ||
=Instructions Using a Single Constant= | =Instructions Using a Single Constant= | ||
<br /> | <br /> | ||
Line 74: | Line 75: | ||
==Number-in-Memory Instructions== | ==Number-in-Memory Instructions== | ||
<br /> | <br /> | ||
+ | These instructions are followed by a number in brackets. This number refers to the location, or ''address'' in memory where the actual operand is located. So, if the number following the instruction is [''100''], it means that the instruction will use whatever number is stored at 100. A simple analogy might help here. Think of the difference between these two statements: "Please read the book ''The Little Prince.''", and the statement "Please read the book from the library, with Call Number PQ2637.A274 P4613 2000". Both statements refer to reading the same book. The first one refers to the book directly, as the instructions in the block above do with their operands. The second statement refers to the book ''indirectly'', by giving you its address in memory. The instructions in this section perform similarly. By putting brackets around the numbers, we indicate that the number used is not the actual number we want to operate with, but the address of the cell where we will find that number. | ||
{| class="wikitable" width="100%" | {| class="wikitable" width="100%" | ||
Line 82: | Line 84: | ||
|- | |- | ||
| | | | ||
− | + | ADD [''address''] | |
| | | | ||
26 | 26 | ||
Line 88: | Line 90: | ||
00011010 | 00011010 | ||
| | | | ||
− | * | + | * This instruction is similar to '''ADD ''number,'' ''' except that now the number to add to the accumulator is located in the memory at the address specified in the instruction. For example, if the memory cell at Address ''20'' contains ''4'', and if the accumulator contains ''10'', then the instruction '''ADD [20]''' |
|- | |- | ||
| | | | ||
− | + | COMP [''address''] | |
| | | | ||
86 | 86 | ||
Line 100: | Line 102: | ||
|- | |- | ||
| | | | ||
− | + | DIV [''address''] | |
| | | | ||
46 | 46 | ||
Line 109: | Line 111: | ||
|- | |- | ||
| | | | ||
− | + | LOAD [''address''] | |
| | | | ||
6 | 6 | ||
Line 118: | Line 120: | ||
|- | |- | ||
| | | | ||
− | + | MUL [''address''] | |
| | | | ||
42 | 42 | ||
Line 127: | Line 129: | ||
|- | |- | ||
| | | | ||
− | + | STORE [''address''] | |
| | | | ||
18 | 18 | ||
Line 136: | Line 138: | ||
|- | |- | ||
| | | | ||
− | + | SUB [''address''] | |
− | + | ||
34 | 34 | ||
| | | |
Revision as of 15:41, 27 August 2014
--D. Thiebaut (talk) 16:57, 26 August 2014 (EDT)
Contents
Instructions Using a Single Constant
These instructions operate with a single number (we refer to them as constants) that is either loaded into, added, or subtracted from the accumulator register.
Instruction | Code (decimal) |
Code ( binary) |
Description |
---|---|---|---|
ADD number |
24 |
00011000 |
|
COMP number |
84 |
01010100 |
|
DIV number |
44 |
00101100 |
|
LOAD number |
4 |
00000100 |
|
MUL number |
40 |
00101000 |
|
SUB number |
32 |
00100000 |
|
Number-in-Memory Instructions
These instructions are followed by a number in brackets. This number refers to the location, or address in memory where the actual operand is located. So, if the number following the instruction is [100], it means that the instruction will use whatever number is stored at 100. A simple analogy might help here. Think of the difference between these two statements: "Please read the book The Little Prince.", and the statement "Please read the book from the library, with Call Number PQ2637.A274 P4613 2000". Both statements refer to reading the same book. The first one refers to the book directly, as the instructions in the block above do with their operands. The second statement refers to the book indirectly, by giving you its address in memory. The instructions in this section perform similarly. By putting brackets around the numbers, we indicate that the number used is not the actual number we want to operate with, but the address of the cell where we will find that number.
Instruction | Code (decimal) |
Code ( binary) |
Description |
---|---|---|---|
ADD [address] |
26 |
00011010 |
|
COMP [address] |
86 |
01010110 |
|
DIV [address] |
46 |
00101110 |
|
LOAD [address] |
6 |
00000110 |
|
MUL [address] |
42 |
00101010 |
|
STORE [address] |
18 |
00010010 |
|
SUB [address] 34 |
00100010 |
|
Number-with-Address-in-Index Instructions
Instruction | Code (decimal) |
Code ( binary) |
Description |
---|---|---|---|
ADDX |
28 |
00011100 |
|
ADDXm |
30 |
00011110 |
|
ADDXx |
29 |
00011101 |
|
ADDx |
25 |
00011001 |
|
COMPX |
92 |
01011100 |
|
COMPXm |
94 |
01011110 |
|
COMPXx |
93 |
01011101 |
|
COMPx |
85 |
01010101 |
|
DIVx |
45 |
00101101 |
|
HALT |
127 |
01111111 |
|
JEQ |
68 |
01000100 |
|
JLT |
72 |
01001000 |
|
JUMP |
64 |
01000000 |
|
LOADX |
8 |
00001000 |
|
LOADXm |
10 |
00001010 |
|
LOADXx |
9 |
00001001 |
|
LOADx |
5 |
00000101 |
|
MULx |
41 |
00101001 |
|
NOP |
0 |
00000000 |
|
STOREXm |
22 |
00010110 |
|
STOREXx |
21 |
00010101 |
|
STOREx |
17 |
00010001 |
|
SUBX |
36 |
00100100 |
|
SUBXm |
38 |
00100110 |
|
SUBXx |
37 |
00100101 |
|
SUBx |
33 |
00100001 |
|
TAX |
79 |
01001111 |
|
TXA |
83 |
01010011 |
|