What does 0x4 do in “movl $0x2d, 0x4(%esp)”?

后端 未结 5 2069
一个人的身影
一个人的身影 2021-02-20 16:46

I am looking into assembly code generated by GCC. But I don\'t understand:

movl $0x2d, 0x4(%esp)

In the second operand, what does 0x4

5条回答
  •  佛祖请我去吃肉
    2021-02-20 17:11

    movl $0x2d, 0x4(%esp) means to take the current value of the stack pointer (%esp), add 4 (0x4) then store the long (32-bit) value 0x2d into that location.

    The eax register is one of the general purpose 32-bit registers. x86 architecture specifies the following 32-bit registers:

    eax  Accumulator Register
    ebx  Base Register
    ecx  Counter Register
    edx  Data Register
    esi  Source Index
    edi  Destination Index
    ebp  Base Pointer
    esp  Stack Pointer
    

    and the names and purposes of some of then harken back to the days of the Intel 8080.

    This page gives a good overview on the Intel-type registers. The first four of those in the above list can also be accessed as a 16-bit or two 8-bit values as well. For example:

    3322222222221111111111
    10987654321098765432109876543210
    <-             eax            ->
                    <-     ax     ->
                    <- ah -><- al ->
    

    The pointer and index registers do not allow use of 8-bit parts but you can have, for example, the 16-bit bp.

提交回复
热议问题