Difference between revisions of "Simple Computer Simulator Instruction-Set"
(→Number-with-Address-in-Index Instructions) |
(→Instructions Using the Index and a Number) |
||
Line 168: | Line 168: | ||
<br /> | <br /> | ||
− | =Instructions | + | =Instructions Manipulating the Index Register= |
<br /> | <br /> | ||
− | The Index is a register in the processor that contains numbers, just as the Accumulator does. | + | The Index, '''IX''' in the simulator, is a register in the processor that contains numbers, just as the Accumulator does. However, the numbers in the index represent addresses of cells containing numbers. The Index is useful is situations where we have several numbers in consecutive memory locations, and we want to perform the same operation on each one, say add 1 to each of the numbers. In this case we store in the Index the address of the first number, say, 100, and operate on that number ''through the Index''. We'll need new instructions for that, but for right now we just want to see how we can load numbers in the index. |
<br /> | <br /> | ||
{| class="wikitable" width="100%" | {| class="wikitable" width="100%" | ||
Line 181: | Line 181: | ||
|- | |- | ||
| | | | ||
− | ADDX | + | ADDX ''number'' |
| | | | ||
28 | 28 | ||
Line 187: | Line 187: | ||
00011100 | 00011100 | ||
| | | | ||
− | * | + | * This instruction adds a number to the contents of the Index register. For example, if the Index register contains the number 10, then '''ADDX ''1'' ''' will add 1 to 10, and the Index will contain 11 after the instruction is executed. |
|- | |- | ||
| | | | ||
Line 196: | Line 196: | ||
00001000 | 00001000 | ||
| | | | ||
− | * | + | * This instruction sets the contents of the Index to the number. For example, '''LOADX ''10'' ''' will result in the number 10 appearing inside the Index register. |
|- | |- | ||
| | | | ||
− | + | STOREX [''address''] | |
| | | | ||
22 | 22 | ||
Line 206: | Line 206: | ||
00010110 | 00010110 | ||
| | | | ||
− | * | + | * This instruction makes a copy of the contents of the Index register and saves it in a cell whose address is the one specified in the instruction. If IX contains 10, then the instruction '''STOREX [''20'']''' will copy the number 10 in the memory cell at Address 20. This does not affect the contents of IX. It does not get change by the copy operation. |
|- | |- | ||
| | | | ||
− | SUBX | + | SUBX ''number'' |
| | | | ||
36 | 36 | ||
Line 215: | Line 215: | ||
00100100 | 00100100 | ||
| | | | ||
− | * | + | *This instruction subtracts a number from the contents of the Index register. For example, if the Index register contains the number 10, then '''SUBX ''1'' ''' will subtract 1 from 10, and the Index will contain 9 after the instruction is executed. |
+ | |- | ||
|} | |} | ||
<br /> | <br /> | ||
+ | |||
= Other = | = Other = | ||
<br /> | <br /> |
Revision as of 19:49, 27 August 2014
--D. Thiebaut (talk) 16:57, 26 August 2014 (EDT)
Contents
This page documents all the instructions that are supported by the Simple Computer Simulator shown below. You can click on the image to go to the Javascript simulator. This simulator is used in the CSC103 How Computers Work course at Smith College.
Simple Computer Simulator
Instructions Using the Accumulator and a Number
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 |
|
Instructions Using Memory
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. The instructions in the section above operate similarly with their operands. The second statement refers to the book indirectly, by giving you its address in the library. The instructions in this section perform the same way. By putting brackets around the numbers that follow the instructions, we indicate that the numbers used are not the actual numbers we want to combine with the accumulator, but the address of the cells where we will find the numbers of interest.
This may still be a bit obscure, but read on the description for each instruction and this will hopefully become a bit clearer.
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 |
|
Instructions Manipulating the Index Register
The Index, IX in the simulator, is a register in the processor that contains numbers, just as the Accumulator does. However, the numbers in the index represent addresses of cells containing numbers. The Index is useful is situations where we have several numbers in consecutive memory locations, and we want to perform the same operation on each one, say add 1 to each of the numbers. In this case we store in the Index the address of the first number, say, 100, and operate on that number through the Index. We'll need new instructions for that, but for right now we just want to see how we can load numbers in the index.
Instruction | Code (decimal) |
Code ( binary) |
Description |
---|---|---|---|
ADDX number |
28 |
00011100 |
|
LOADX number |
8 |
00001000 |
|
STOREX [address] |
22 |
00010110 |
|
SUBX number |
36 |
00100100 |
|
Other
|-
|
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 |
|-
|
LOADXm
|
10
|
00001010
|
|- | LOADXx | 9 | 00001001 |
|- | LOADx | 5 | 00000101 |
|-
|
MULx
|
41
|
00101001
|
|- | NOP | 0 | 00000000 |
|- | STOREXx | 21 | 00010101 |
|- | STOREx | 17 | 00010001 |
|-
|
SUBXm
|
38
|
00100110
|
|- | SUBXx | 37 | 00100101 |
|- | SUBx | 33 | 00100001 |
|- | TAX | 79 | 01001111 |
|- | TXA | 83 | 01010011 |
|- |}