MGMT 1030 Lecture Notes - Lecture 7: Opcode
MGMT 1030 Tutorial 7 Notes – Negative Values
Introduction
• The Little Man walks over to the calculator and reads the number there.
• He writes that number on a slip of paper and puts it in the mailbox whose address was
specified as the address part of the instruction.
• The number in the calculator is unchanged
• The original number in the mailbox is replaced with the new value.
• ADD instruction—op code 1
• This instruction is very similar to the LOAD instruction.
• The Little Man walks over to the mailbox address specified in the instruction.
• He reads the three-digit number located in the mailbox
• Then walks over to the calculator and adds it to the number already in the calculator.
• The number in the mailbox is unchanged.
• SUBTRACT instruction—op code 2
• This instruction is the same as the ADD instruction
• Except that the Little Man subtracts the mailbox value from the value in the calculator.
• The result of a subtraction can leave a negative value in the calculator.
• The use of complements to implement negative values, but for simplicity, the LMC
model ignores this solution.
• For the purposes of our LMC model, we will simply assume that the calculator holds
• Handles negative values correctly, and provides a minus sign as a flag to indicate that
the value is negative.
• The Little Man cannot handle negative numbers outside of the calculator
• However, because there is no provision in the model for storing the negative sign within
the constraint of the three-digit number system used.
• INPUT instruction (or read, if you prefer)—op code 9, address
• The Little Man walks over to the in basket and picks up the slip of paper in the basket.
• He then walks over to the calculator and punches it into the calculator.
find more resources at oneclass.com
find more resources at oneclass.com