Wednesday 9 March 2016

Little Man Computer

The basic commands used within LMC:




















LMC Homework:

Task 1:
INP - the first value is inputted
STA FIRST - the input is stores in the memory address FIRST
INP - the second value is inputted
ADD FIRST - Add the value in the memory address FIRST to the second value inputted
OUT - the result is then outputted
INP - the third value is inputted
SUB FIRST - Subtract the value in the memory address FIRST from the third value inputted
OUT - the result is outputted
HLT - Finish the program

FIRST DAT - Declare FIRST as the next available memory address

Task 2:
INP - the first value is inputted
STA FIRST - Store the value in the memory address FIRST
INP - input a second value
STA SECOND - Store the second value in the memory address SECOND
LDA FIRST - Load the value in the memory address FIRST
OUT - Output this value (found in FIRST)
LDA SECOND - Load the value in the memory address SECOND
OUT - Output this value (found in SECOND)
HLT - Finish the program

FIRST DAT - Declare FIRST as the next available memory address
SECOND DAT - Declare SECOND as the next available memory address (after FIRST)

This program in LMC accepts inputs of values and then remembers them and stores then in different mailboxes to then be accessed at a later time.

No comments:

Post a Comment