2

I'm having trouble comparing two numbers in MARIE (Machine Simulator Environment), for some reason I just can't seem to get my head around it.

All I need the code to do is; allow the user to input 2 numbers then compare them and if the two numbers are the same output a 1 and if they aren't the same output a 0.

So far I've got the bare minimum so any and all help is highly appreciated!

I've tried this:

INPUT 
STORE X 
INPUT 
STORE Y 
HALT 
X, DEC 010 
Y, DEC 011 
BradBeighton
  • 83
  • 1
  • 9

1 Answers1

1

Have one variable to store input. Then subtract the next input from it. If the result is zero skip to print a 0. Otherwise print a 1 and then jump to the end of the program

    Input
    Store Num

    Input
    Subt Num
    Skipcond 400 
    Jump Equal  /If zero the numbers are equal

    Load One
    Output
    Jump End

Equal, Load Zero
    Output
End, Halt

/ declarations
Num, Dec 0
Zero, Dec 0
One, Dec 1