3

Below is the disassembly of the beginning of a function. The first mention of the edx register is "sarl $0x3, %edx", which shifts the exiting value. As I understand it, the value of the edx register is undefined when entering a function. Can anyone explain what is going on here? Thanks.

00007672    pushl   %ebp
00007673    movl    %esp, %ebp
00007675    pushl   %edi
00007676    pushl   %esi
00007677    pushl   %ebx
00007678    calll   0x767d
0000767d    popl    %ebx
0000767e    subl    $0x9c, %esp
00007684    movl    0x14(%ebp), %edi
00007687    movl    0x10(%ebp), %esi
0000768a    calll   __ZN9Node11GetInstanceEv
0000768f    movl    $0x66666667, %ecx
00007694    movl    %eax, -0x8c(%ebp)
0000769a    movl    %esi, %eax
0000769c    imull   %ecx
0000769e    movl    -0x8c(%ebp), %eax
000076a4    sarl    $0x1f, %esi
000076a7    sarl    $0x3, %edx
000076aa    subl    %esi, %edx
000076ac    cvtsi2ssl   %edx, %xmm0
000076b0    leal    -0x2c(%ebp), %esi
Dim St Thomas
  • 103
  • 1
  • 7
  • 3
    Check the documentation for `imul`. – fuz Feb 14 '18 at 19:32
  • 5
    `edx` is an implicit (destination) operand of `imul`. – JFMR Feb 14 '18 at 19:33
  • Thank you for your quick and helpful replies. Yes, you are right, imul with one argument sets edx to the result. – Dim St Thomas Feb 14 '18 at 20:25
  • related: [Why does GCC use multiplication by a strange number in implementing integer division?](https://stackoverflow.com/questions/41183935/why-does-gcc-use-multiplication-by-a-strange-number-in-implementing-integer-divi). Looks like signed 32-bit division by a constant. – Peter Cordes Feb 14 '18 at 22:52

0 Answers0