大会 - jg当期待jle

时间:2018-03-02 03:09:48

标签: c assembly

有人可以解释一下为什么下面的C代码在汇编而不是jle中生成jg跳转语句吗?

#include <stdio.h>

  int foo(int a, int b)
  {
    if (a<=b) return a;
      else return b;
  }//end foo

 int main()
 {
  return  foo(1,2);
 }//end main



Dump of assembler code for function foo:
0x080483db <+0>:    push   %ebp
0x080483dc <+1>:    mov    %esp,%ebp                
0x080483de <+3>:    mov    0x8(%ebp),%eax       # eax = a
0x080483e1 <+6>:    cmp    0xc(%ebp),%eax       # a - b
0x080483e4 <+9>:    jg     0x80483eb <foo+16>   # my interpretation "if a > b goto 16"  ***Why does this not use JLE???***
0x080483e6 <+11>:   mov    0x8(%ebp),%eax       # return a 
0x080483e9 <+14>:   jmp    0x80483ee <foo+19>   # goto 19
0x080483eb <+16>:   mov    0xc(%ebp),%eax       # return b
0x080483ee <+19>:   pop    %ebp                 
0x080483ef <+20>:   ret   

0 个答案:

没有答案