0

I'm converting assembly code to C code and I'm confused about part of the codes. I knew that after imul, the higher and lower part of tmp1*tmp2 will be stored in %edx and %eax separately. However, I'm confused that
1, why it stores tmp1 into %eax (line 132d) again? I think it will erase the value of tmp3in %eax.
2, In line 1332, the instruction uses %edx. I know it should be the upper part of tmp3, but how can I represent it in C code?
3, Why there is nop in line 1339?

    //prologue
    1306:   f3 0f 1e fb             endbr32 
    130a:   55                      push   %ebp
    130b:   89 e5                   mov    %esp,%ebp
    //body
    130d:   8b 45 0c                mov    0xc(%ebp),%eax      
    1310:   8b 00                   mov    (%eax),%eax           
    1312:   8b 55 08                mov    0x8(%ebp),%edx           //%edx<-para1
    1315:   c1 e2 03                shl    $0x3,%edx                //para1<<3
    1318:   01 c2                   add    %eax,%edx              //para1+=*para2
    131a:   8b 45 0c                mov    0xc(%ebp),%eax           //%eax<-para2
    131d:   89 10                   mov    %edx,(%eax)              
    131f:   8b 45 0c                mov    0xc(%ebp),%eax           //
    1322:   8b 08                   mov    (%eax),%ecx              
    1324:   ba 56 55 55 55          mov    $0x55555556,%edx     
    1329:   89 c8                   mov    %ecx,%eax                //%eax<-tmp1
    132b:   f7 ea                   imul   %edx                     //long tmp3=tmp1*tmp2
    132d:   89 c8                   mov    %ecx,%eax                //%eax<-tmp1
    132f:   c1 f8 1f                sar    $0x1f,%eax               //tmp1>>31
    1332:   29 c2                   sub    %eax,%edx                //?
    1334:   8b 45 0c                mov    0xc(%ebp),%eax
    1337:   89 10                   mov    %edx,(%eax)
    1339:   90                      nop
    133a:   5d                      pop    %ebp
    133b:   c3                      ret 

Thank you so much~

0 Answers0