Lopez, Ferdinand Jr. B.
IT 111
1-15-09
LMC (Little Man Computer) The LMC model is based on the concept of a little man locked in a small room. At one end of the room, there are 100 mailboxes (Memory), numbered 0 to 99, that can each contain a 3 digit instruction. Furthermore, there are two mailboxes at the other end labeled INBOX and OUTBOX which are used for receiving and outputting data. In the center of the room, there is a work area containing a simple 2 function (addition and subtraction) calculator known as the Accumulator and a resettable counter known as the Program Counter. The Program Counter is similar to what a doorperson uses to keep track of how many people have entered a facility – it can count up 1, or it can be reset to 0. As specified by the Von Neumann architecture, memory contains both instructions and data. The user loads data into the mailboxes and the signals the little man to begin execution.
The little man performs the following steps to execute a program:
1. 2. 3. 4. 5. 6. 7. 8.
Check the Program Counter for the mailbox number that contains a program instruction Fetch the instruction from the mailbox with that number Increment the Program Counter (so that it contains the mailbox number of the next instruction) Decode the instruction (includes finding the mailbox number for the data it will work on) Fetch the data from the mailbox with the number found in the previous step Execute the instruction Store the new data in the mailbox from which the old data was retrieved Repeat the cycle or halt
LMC commands: numeric 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. Instructions • • • • • • • •
• •
1xx – ADD – Take the value stored in mailbox xx and add it to whatever value is currently on the accumulator. 2xx – SUBTRACT – Take the value stored in a mailbox xx and subtract it from whatever value is currently on the accumulator 3xx – STORE – Take the value from the accumulator (non-destructive) and enter it in the accumulator 5xx – LOAD – Take the value from mailbox xx (non-destructive) and enter it in the accumulator (destructive) 6xx – BRANCH (unconditional) – Reset the program counter to the value xx. That is, xx will be the next instruction executed. 7xx – BRANCH IF ZERO - If the accumulator contains the value 0, reset the program counter to the value xx. Otherwise, do nothing. 8xx – BRANCH OF POSITIVE – If the accumulator is 0 or positive, reset the program counter to the value xx. Otherwise, do nothing. 901 – INPUT - Go to the INBOX, fetch the value from the user, and put it in the accumulator (destructive) 902 – OUTPUT – Fetch the value from the accumulator (non-destructive), and put it in the OUTBOX for the user to read. 000 – HALT – Stop working.
Mr. Daniel Bayog