Instructions
Each LMC instruction is a 3 digit decimal number. The first digit represents the command to be performed and the final two digits represent the address of the mailbox affected by the command.
Numeric code | Mnemonic code | Instruction | Description |
---|---|---|---|
1xx | ADD | ADD | Add the value stored in mailbox xx to whatever value is currently on the accumulator (calculator).
|
2xx | SUB | SUBTRACT | Subtract the value stored in mailbox xx from whatever value is currently on the accumulator (calculator).
|
3xx | STA | STORE | Store the contents of the accumulator in mailbox xx (destructive).
|
5xx | LDA | LOAD | Load the value from mailbox xx (non-destructive) and enter it in the accumulator (destructive). |
6xx | BRA | BRANCH (unconditional) | Set the program counter to the given address (value xx). That is, value xx will be the next instruction executed. |
7xx | BRZ | BRANCH IF ZERO (conditional) | If the accumulator (calculator) contains the value 000, set the program counter to the value xx. Otherwise, do nothing.
|
8xx | BRP | BRANCH IF POSITIVE (conditional) | If the accumulator (calculator) is 0 or positive, set the program counter to the value xx. Otherwise, do nothing.
|
901 | INP | INPUT | Go to the INBOX, fetch the value from the user, and put it in the accumulator (calculator)
|
902 | OUT | OUTPUT | Copy the value from the accumulator (calculator) to the OUTBOX.
|
000 | HLT | HALT | Stop working. |
DAT | DATA | This is an assembler instruction which simply loads the value into the next available mailbox. DAT can also be used in conjunction with labels to declare variables. For example, DAT 984 will store the value 984 into a mailbox. |
Read more about this topic: Little Man Computer, Commands
Famous quotes containing the word instructions:
“Realizing that his time was nearly spent, he gave full oral instructions about his burial and the manner in which he wished to be remembered.... A few minutes later, feeling very tired, he left the room, remarking, I have no disposition to leave this precious circle. I love to be here surrounded by my family and friends. Then he gave them his blessing and said, I am ready to go and I wish you goodnight.”
—For the State of New Hampshire, U.S. public relief program (1935-1943)
“If we consider what happens in conversation, in reveries, in remorse, in times of passion, in surprises, in the instructions of dreams, wherein often we see ourselves in masquerade,the droll disguises only magnifying and enhancing a real element, and forcing it on our distinct notice,we shall catch many hints that will broaden and lighten into knowledge of the secret of nature.”
—Ralph Waldo Emerson (18031882)
“They had supposed their formula was fixed.
They had obeyed instructions to devise
A type of cold, a type of hooded gaze.
But when the Negroes came they were perplexed.
These Negroes looked like men....”
—Gwendolyn Brooks (b. 1917)