Share
Explore BrainMass

Little Man Computer: Higher of two numbers

The following LMC (Little Man Computer) program is supposed to input two numbers, compare them, and output the higher of the two numbers. There is something wrong with this program but I can not figure it out. Please help me fix it.

Mailbox Mnemonic Code
01 IN 901
02 STO 90 390
03 IN 901
04 STO 91 391
05 SUB 90 290
06 BRP 10 810
07 LDA 91 591
08 OUT 902
09 COB 000
10 LDA 90 590
11 OUT 902
12 COB 000

Solution Preview

Your given program must be looking something like below in source form.

IN
STO FST
IN
STO SND
SUB FST
BRP FGS
LDA SND
OUT
COB
FGS LDA FST
OUT
COB
FST DAT ...

Solution Summary

For ease of understanding, solution works with the equivalent source code form of the given program. It first explains the cause of the bug in the given program and then gives the solution to fix that.

$2.19