# An example of using the CMP and JGE instruction
.section .data
output:
.asciz "The jump or not jump value is %d\n"
.section .text
.globl main
main:
nop
movl $10, %eax
movl $15, %ebx
cmp %eax, %ebx # ebx-eax=15-10 --> ebx > eax, jump greater
jge greater
push %ebx
push $output
call printf # printf(output, ebx)
add $8, %esp # 还原esp
movl $1, %eax
int $0x80
greater:
movl $20, %ebx
push %ebx
push $output
call printf
add $8, %esp
movl $1, %eax
int $0x80
# gcc -o 04-cmp 04-cmp.s -m32
# The largest value is 20
# note
# cmp operand1, operand2
# 使用GUN汇编器时,cmp指令中, operand1 和 operand2 的顺序与Intel文档中的顺序是相反的。