LMC Load and Save Instructions
The following program will demonstrate the load and save
instructions of the LMC.
Program
INP
STA FIRST
INP
STA SECOND
LDA FIRST
OUT
LDA SECOND
OUT
HLT
FIRST DAT
SECOND DAT
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 eleven line program above and paste it into the Message
Box
- Click on the "Compile Program" button.
- Click on the "Run" button.
- When prompted, enter three-digit numbers in the "In-Box", and
press the "Enter" button.
What you should see
- After the program is compiled, you should see from mailbox 0 to 7
the instructions 901, 309, 901, 310, 509, 902, 510, 902. The
Program Counter
should start at 0
(click on "Reset" if necessary).
- DAT is the tenth and eleventh instruction of your program, so
they refer to
mailboxes 9 and 10 (0-indexed counting). FIRST and SECOND are the
identifiers that have
been declared to represent these mailboxes in the assembly language
program.
- When you click on "Run" or "Step", the Message Box will describe
the actions of each instruction.
- After the first INP instruction, the Accumulator has a copy of
the
first value entered in the In Box.
- After the STA instruction, the input value is copied from the
Accumulator to mailbox 9 -- 3 means STORE and 09 refers to the mailbox
to store into.
- After the second INP instruction, the Accumulator has a copy of
the
second value entered into the In Box (use a different value than the
first).
- After the second STA instruction, the second input value is
copied from the
Accumulator to mailbox 10.
- After the LDA instruction, the Accumulator is reset to the first
input value. This value has been retrieved from mailbox 9 -- 5
means LOAD and 09 refers to the mailbox to load from. Note: since
your Accumulator can only work on one value at a time, you have to
repeatedly STORE and LOAD values from memory to keep them from getting
erased by the next operation.
- After the OUT instruction, the Out Box has a copy of the value in
the Accumulator -- the first input value.