An LMC (Little Man Computer) can be imagined to have certain resources available for the little man to use: input and output "trays", a calculator, a collection of numbered "mailboxes", and a counter to keep track of which mailbox the "little man" should look in for his next instruction.
Code | Meaning |
---|---|
1xy | copy value from Mailbox with the supplied Mailbox number (xy) to the Calculator |
2xy | replace the number in the Mailbox at the supplied Mailbox number with the current Calculator value |
3xy | add the value in the Mailbox at the supplied Mailbox number to the Calculator |
4xy | subtract the value in the Mailbox at the supplied Mailbox number from the value in the Calculator |
500 | copy the value currently in the Input basket to the Calculator |
600 | copy the value from the Calculator to the Output basket |
700 | stop processing |
800 | skip the next instruction (i.e. increment the Counter an extra time) if the Calculator Negative indicator is on |
801 | skip the next instruction if the Calculator Zero indicator is on |
802 | skip the next instruction if the Calculator Zero or Positive indicators are on |
9xy | re-set the counter to (xy) |
As a first step in the fixed routine, the "little man" must get the instruction telling him what he should do next.
The incrementing of the Counter must occur before instruction execution, as will become obvious when we look at instructions whose execution modifies the value in the Counter.
These three major activities are called: Fetch, Increment, and Execute. Every computer does this.