LMC Add and Subtract Instructions

The following program will demonstrate the add and subtract instructions of the LMC.  Note: The Accumulator (calculator) in the LMC is only designed to work with non-negative three-digit numbers.  Mathematical operations which produce values greater than 999 or less than 000 can cause undefined effects to occur. 

Program

INP
STA FIRST
INP
ADD FIRST
OUT
INP
SUB FIRST
OUT
HLT
FIRST DAT

What you should do

  1. Click on the "LMC Simulator Applet" link to start the LMC simulator.
  2. Clear the Message Box and all of the LMC mailboxes -- click the "Clear Messages" button and the "Clear" button if necessary.
  3. Copy the ten line program above and paste it into the Message Box
  4. Click on the "Compile Program" button.
  5. Click on the "Run" button.
  6. When prompted, enter three-digit numbers in the "In-Box", and press the "Enter" button.

What you should see