Quantcast
Channel: understanding some assembly code - Stack Overflow
Viewing all articles
Browse latest Browse all 3

understanding some assembly code

$
0
0

I am trying to learn some assembly code, so I read in some tutorial that the assembly code for

int proc(void)  {      int x,y;       scanf("%x %x", &y, &x);       return x-y;   }

is

1   proc:2     pushl  %ebp3     movl  %esp, %ebp4     subl   $40, %esp5     leal  -4(%ebp), %eax6     movl  %eax, 8(%esp)7     leal  -8(%ebp), %eax8     movl  %eax, 4(%esp)9     movl  $.LC0, (%esp)10    call  scanf Diagram stack frame at this point11    movl  -4(%ebp), %eax12    subl  -8(%ebp), %eax13    leave14    ret

If I well understood, the instructions of line 5 to 8 store some addresses that will be used to store the values of scanf's input. So is it right to say that scanf uses systematically the address %esp plus a certain number of bytes (depending on the sizeof the input) to fetch the address at which is the data will be stored ?


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images