The program is designed to subtract the first input by the second and if the result is positive or zero then input 1 is bigger (or the same) so input 1 is outputed first. This all works fine when the first number is bigger but when the first number is smaller it still runs the 'if positive' loop even though the result of the subtraction is negative. I don't understand why this happens but I hope someone with more experience with this program can help.
INP
STA VONE
INP
STA VTWO
LDA VONE
SUB VTWO
STA NUM
LDA NUM
BTOS LDA VONE
OUT
LDA VTWO
OUT
BRA LOOP
BRP BTOS
LDA VTWO
OUT
LDA VONE
OUT
BRA LOOP2
The BRA LOOP
is a different part of the program, which works correctly, so you can ignore it.