Instructions
Little Man Computer has a small group of instructions that resemble the object code, or the machine language of today's processors.
The instruction set of Little Man Computer consists of two addressing modes, direct as well as indirect addressing. In case of direct addressing, the data is specified as part of the instruction, where as in Indirect addressing, the data is located by the mailbox whose address is specified as part of the instruction.
Each instruction consists of a single digit. The first digit of a three-digit number will tell the Little Man which operation to perform. In some instructions, a particular mailbox may be required for storing or retrieving data. Since the instruction requires only one digit, we can use the other two digits in a three-digit number to indicate the appropriate mailbox. Indirect addressing mode is specified by placing a '*' in front of the data portion of the instruction.
Direct Addressing |
Instruction |
Mnemonic |
Opcode |
Description |
| LOAD | LDA XX | 1XX | The three-digit number located in the mailbox specified by the instruction is loaded into the calculator. The three-digit number in the mailbox is left unchanged, but the new number replaces the original number in the calculator. | |
| STORE | STA XX | 2XX | This instruction is the reverse of the LOAD instruction. The
three-digit number located in the calculator is loaded into the mailbox specified by the
instruction. The three-digit number in the calculator is left unchanged, but the new
number replaces the original number in the mailbox. |
|
| ADD | ADD XX | 3XX | The three-digit number located in the mailbox specified by the
instruction is added to the contents of the calculator and is displayed on the calculator. The contents of the calculator is changed to the new number, but the mailbox is left unchanged. |
|
| SUB | SUB XX | 4XX | This instruction works similar to the ADD instruction. Only
the number is subtracted and not added. |
|
| INPUT | IN | 500 | The data in the in-basket is read and placed in the
calculator. The number is no longer in the in-basket, and the new number replaces the original calculator value. The address portion of the instruction is ignored. |
|
| OUTPUT | OUT | 600 | The number in the calculator is written to the out-basket. The
original number in the calculator is unchanged. Again the address portion of the instruction is ignored. |
|
| HALT | HLT | 700 | The little man takes a rest. The address portion of the
instruction is ignored. |
|
| SKIP | SKN | 800 | Skip if result in calculator is negative. | |
| SKZ | 801 | Skip if result in calculator is zero. | ||
| SKP | 802 | Skip if result in calculator is zero or positive. | ||
| JUMP | JMP XX | 9XX | The value of the location counter is changed to the number specified
in the instruction. This means that the next instruction that will be executed is located at that mailbox address. |
|
Indirect Addressing |
Instruction |
Mnemonic |
Opcode |
Description |
| LOAD | LDA *XX | *1XX | The three-digit number located in the mailbox pointed by the contents of location xx is loaded into the calculator. The three-digit number in the mailbox is left unchanged, but the new number replaces the original number in the calculator. | |
| STORE | STA *XX | *2XX | This instruction is the reverse of the LOAD instruction. The three-digit number located in the calculator is loaded into the mailbox pointed by the contents of location xx. The three-digit number in the calculator is left unchanged, but the new number replaces the original number in the mailbox. | |
| ADD | ADD *XX | *3XX | The three-digit number located in the mailbox pointed by the contents of location xx is added to the contents of the calculator and is displayed on the calculator. The contents of the calculator is changed to the new number, but the mailbox is left unchanged. |
|
| SUB | SUB *XX | *4XX | This instruction works similar to the Indirect mode ADD instruction. Only the number is subtracted and not added. | |
| JUMP | JMP *XX | *9XX | The value of the location or hand counter is changed to the number located in the mailbox pointed by the contents of location xx. | |
Immediate Addressing |
Instruction |
Mnemonic |
Opcode |
Description |
| LOAD | LDA #XX | #1XX |
Loads the number XX specified in the instruction into the calculator. |
|
| ADD | ADD #XX | #3XX | Adds the number XX specified in the instruction into the calculator. | |
| SUB | SUB #XX | #4XX | Subtracts the number XX specified in the instruction from the calculator. |