如何区分while循环与x86汇编中的if语句? 说我的程序得到这个x86汇编:而如果在x86程序集中
jmp .L2 # jump to test at end
.L4:
movl -4(%ebp), %eax # eax = A
cmpl -12(%ebp), %eax # compare A to C
jge .L3 # skip next statement if A >= C
addl $1, -4(%ebp) # A++
.L3:
subl $1, -8(%ebp) # B--
.L2:
cmpl $0, -8(%ebp) # compare B to 0
jns .L4 # restart code if B >= 0
说X位于-8(%EBP), 在.L2的底部,这是为什么while循环?
为什么是: while(x >= 0){jump to .L4}
,而不是: if(x >= 0){ jump to .L4}
?
我不明白你的问题。是什么让你认为.L2作为一个while循环?它做了一个比较,然后跳转或不跳转,就像if语句一样。 – kronion