What is the assembler syntax to determine which of two numbers is greater?
What is the lower level (machine code) for it? Can we go even lower? Once we get to the bi
The basic technique (on most modern systems) is to subtract the two numbers and then to check the sign bit of the result, i.e. see if the result is greater than/equal to/less than zero. In the assembly code instead of getting the result directly (into a register), you normally just branch depending on the state:
; Compare r1 and r2
CMP $r1, $r2
JLT lessthan
greater_or_equal:
; print "r1 >= r2" somehow
JMP l1
lessthan:
; print "r1 < r2" somehow
l1: