LMC Input and Output Instructions
The following program will demonstrate the input and output
instructions of the LMC. The first instruction will copy a
three-digit number from the In Box to the accumulator, and the second
instruction will copy the value of the accumulator to the Out Box.
Program
INP
OUT
HLT
What you should do
- Click on the "LMC Simulator Applet" link to start the LMC
simulator.
- Clear the Message Box and all of the LMC mailboxes -- click
the "Clear Messages" button and the "Clear" button if necessary.
- Copy the three-line program above and paste it into the Message
Box
- Click on the "Compile Program" button.
- Click on the "Run" button.
- When prompted, enter a three-digit number in the "In-Box", and
press the "Enter" button.
What you should see
- After the program is compiled, you should see 901 in mailbox 0
and 902 in mailbox 1. The Program Counter should start at 0
(click on "Reset" if necessary).
- When you click on "Run" or "Step", the Message Box will describe
the actions of each instruction.
- After the INP instruction, the Accumulator has a copy of the
value in the In Box.
- After the OUT instruction, the Out Box has a copy of the value in
the Accumulator.
- The final value of the Program Counter is 2. This mailbox
holds 0 - the machine code instruction that tells the LMC to stop
executing your program.