INP
STA NUM1
INP
STA NUM2
SUB NUM1
BRP NUM2SHOW
LDA NUM1
SUB NUM2
BRP NUM1SHOW
#NUM1 > NUM2
NUM1SHOW LDA NUM1
OUT
HLT
#NUM2 > NUM1
NUM2SHOW LDA NUM2
OUT
HLT
NUM1 DAT
NUM2 DAT
Here is the code block, just looking at it, it seems like it's correct but for some reason it does not show anything when I ran the code.
I'm expecting for it to show the larger number. I've been using 4 as the first number at 5 as the second number, though like I said, it does not show anything at all.
Your program works in several different simulators, so your problem is probably a misunderstanding in using the tooling.
There's at least 5 LMC simulators out there, mostly web-based / online. I like https://blog.paulhankin.net/lmc/lmc.html for an LMC simulator as a simple and effective LMC simulator.
To critique your program, there's more logic than needed for this.
Your doing something like:
This test for x < y and then x > y is redundant. We would normally write something like this using an if-then-else, which chooses to run the then-part or the else-part with a single condition test1:
While relevant, the above doesn't fully capture the redundancy. Let's switch to if-goto-label to see more:
Here you can see that the second if statement either does the
goto print_xor doesn't. But where does it go next when it doesn't run the goto in the then-part? It goes toprint_x:by default as the next statement. So, that means the second test either doesgoto print_xor doesn't but either way still ends up executingprint_x:as next statement after — so, that if statement doesn't do anything to inform the program.1 To do an if-then-else in assembly we test a condition, and goto the else part if the condition isn't met. The then-part will execute when the condition is met, and then then-part must, when completed, skip the else-part. In other words, the control flow either executes the then-part or the else-part, but only one of them — the other one is skipped one way or the other.