现在的位置: 首页 > 综合 > 正文

反汇编之c语言if…elseif…

2012年02月29日 ⁄ 综合 ⁄ 共 1931字 ⁄ 字号 评论关闭

贴主要反汇编代码:

    47:  if(i>0 && i<10)
00E33559  cmp         dword ptr [i],0 
00E3355D  jle         test+5Eh (0E3357Eh) 
00E3355F  cmp         dword ptr [i],0Ah 
00E33563  jge         test+5Eh (0E3357Eh)  任何一个不成立都跳到下一个else
    48:  {
    49:   printf("0<i<10");

00E33565  mov         esi,esp 
00E33567  push        offset string "0<i<10" (0E35754h) 
00E3356C  call        dword ptr [__imp__printf (0E382B0h)] 
00E33572  add         esp,4 
00E33575  cmp         esi,esp                          vc编译器生成的
00E33577  call        @ILT+295(__RTC_CheckEsp) (0E3112Ch)  vc编译器生成的
00E3357C  jmp         test+9Ah (0E335BAh)    跳出if...else语句
    50:  }else if(i > 10 && i < 100)
00E3357E  cmp         dword ptr [i],0Ah 
00E33582  jle         test+83h (0E335A3h) 
00E33584  cmp         dword ptr [i],64h 
00E33588  jge         test+83h (0E335A3h)  任何一个不成立都跳到下一个else
    51:  {
    52:   printf("10<i<100");

00E3358A  mov         esi,esp 
00E3358C  push        offset string "10<i<100" (0E35748h) 
00E33591  call        dword ptr [__imp__printf (0E382B0h)] 
00E33597  add         esp,4 
00E3359A  cmp         esi,esp 
00E3359C  call        @ILT+295(__RTC_CheckEsp) (0E3112Ch) 
    53:  }else
00E335A1  jmp         test+9Ah (0E335BAh)  跳出if...else语句
    54:  {
    55:   printf("i<0,i>100");

00E335A3  mov         esi,esp 
00E335A5  push        offset string "i<0,i>100" (0E3573Ch) 
00E335AA  call        dword ptr [__imp__printf (0E382B0h)] 
00E335B0  add         esp,4 
00E335B3  cmp         esi,esp 
00E335B5  call        @ILT+295(__RTC_CheckEsp) (0E3112Ch) 
    56:  }
00E335BA  push        edx                         

 

 

 

A:cmp   <变量>,<常量>

jle   B

cmp   <变量>,<常量>

jge  B

A:(条件成立的执行语句)

跳出 if语句

 

B:cmp   <变量>,<常量>

jle   C

cmp   <变量>,<常量>

jge  C

B:(条件成立的执行语句)

跳出 if语句

 

.....................

 

N:(最后一个else语句)

 

 

 把&&换成||的改动不大

if(i<'a' || i>'z')
002A3559  cmp         dword ptr [i],61h 
002A355D  jl          test+45h (2A3565h)      执行条件成立代码
002A355F  cmp         dword ptr [i],7Ah 
002A3563  jle         test+5Eh (2A357Eh)     跳到else

 

 

抱歉!评论已关闭.