Results 1 to 2 of 2

Thread: Help with assembly code

  1. #1
    Join Date
    Feb 2009
    Posts
    2,155
    Mentioned
    4 Post(s)
    Quoted
    42 Post(s)

    Default Help with assembly code

    Consider the following code

    Code:
       0x080493c4 <+0>:	sub    $0x2c,%esp
       0x080493c7 <+3>:	mov    0x34(%esp),%eax
       0x080493cb <+7>:	lea    0x14(%eax),%edx
       0x080493ce <+10>:	mov    %edx,0x1c(%esp)
       0x080493d2 <+14>:	lea    0x10(%eax),%edx
       0x080493d5 <+17>:	mov    %edx,0x18(%esp)
       0x080493d9 <+21>:	lea    0xc(%eax),%edx
       0x080493dc <+24>:	mov    %edx,0x14(%esp)
       0x080493e0 <+28>:	lea    0x8(%eax),%edx
       0x080493e3 <+31>:	mov    %edx,0x10(%esp)
       0x080493e7 <+35>:	lea    0x4(%eax),%edx
       0x080493ea <+38>:	mov    %edx,0xc(%esp)
       0x080493ee <+42>:	mov    %eax,0x8(%esp)
       0x080493f2 <+46>:	movl   $0x804a681,0x4(%esp)
       0x080493fa <+54>:	mov    0x30(%esp),%eax
       0x080493fe <+58>:	mov    %eax,(%esp)
       0x08049401 <+61>:	call   0x80488d0 <__isoc99_sscanf@plt>
       0x08049406 <+66>:	cmp    $0x5,%eax
       0x08049409 <+69>:	jg     0x8049410 <read_six_numbers+76>
       0x0804940b <+71>:	call   0x8049385 <explode_bomb>
       0x08049410 <+76>:	add    $0x2c,%esp
       0x08049413 <+79>:	ret
    The function is called read_six_numbers

    I get what most of it is doing, but my question is what is the 0xYY doing?

    For example in the line

    Code:
    mov    0x34(%esp),%eax
    what is the 0x34 doing to %esp?



    I am an assembly noob

  2. #2
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    That's an example of the base-plus-offset addressing mode. In that case, %esp is the base and 0x34 is the offset, so the value at address [%esp + 0x36] will be loaded and stored into %eax.
    :-)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •