Little Man Computer Code Write a program to input 3 numbers
Little Man Computer Code.
Write a program to input 3 numbers and then output the highest AND the lowest.
Here is a link to a PDF that will help
http://www.ictresources.net/uploads/2/9/2/6/29262609/the_little_man_computer.pdf
to check code here: http://peterhigginson.co.uk/LMC/
Note: the code should look like something like that:
INP
STA 99
INP
ADD 99
OUT
HLT
Solution
solution:
INP // Read the 1st value
STA 91 // store
INP // Read the 2nd value
STA 92 // store
INP // Read in the 3rd value
STA 93 // store
LDA 92 // LOOP 1 and STEP 1:
SUB 91 //
BRP STEP2 // if both the r91 and r92 are in order, then don\'t swap them
LDA 92 // start with swapping registers
STA 99 // temp = r92
LDA 91
STA 92 // r92 = r91
LDA 99
STA 91 // r91 = temp
STEP2 LDA 93 // LOOP 1 and STEP 2
SUB 92
BRP STEP3 // If both the r92 and r93 are in order,then don\'t swap them
LDA 93 // start swapping registers
STA 99 // temp = r93
LDA 92
STA 93 // r93 = r92
LDA 99
STA 92 // r92 = temp
STEP3 LDA 92 // LOOP 2 and STEP 1
SUB 91
BRP STEP4 // if both r91 and r92 are in order, then don\'t swap them
LDA 92 // start swapping registers
STA 99 // temp = r92
LDA 91
STA 92 // r92 = r91
LDA 99
STO 91 // r91 = temp
STEP4 LDA 91 // please Write the sorted values
OUT
LDA 92
OUT
LDA 93
OUT
HLT // over/finsh

