cmp ax, bx ;; computes ax - bx ;; Set the flags according to result |
je jump when equal jne jump when not equal jl jump when less than jle jump when less than or equal jg jump when greater than jge jump when greater than or equal jmp unconditional jump |
cmp eax, ebx ;; computes EAX - EBX jg next ;; jump to "next" when EAX > EBX |
int x, y;
if ( x >= y )
System.out.print( x + " >= " + y );
else
System.out.print( x + " < " + y );
|
Intel Assembler code:
.data
Str1 db "%d >= %d", 13, 10, 0
Str2 db "%d < %d", 13, 10, 0
x dd 40
y dd 6
.code
start:
mov eax, x
mov edx, y
cmp eax, edx ;; x - y
jl Else1 ;; jump if x < y
;; Then part: x >= y
push y
push x
push offset Str1
call crt_printf
jmp Done
;; Else part: x < y
Else1:
push y
push x
push offset Str2
call crt_printf
Done:
|