Linux X86-64 assembly and printf

前端 未结 1 622
遥遥无期
遥遥无期 2021-01-03 06:46

I am reading some linux assembly manuals and found idea about using printf() function. I need it to output register values for debugging reasons in binary form to terminal,

相关标签:
1条回答
  • 2021-01-03 07:30

    Linux (and Windows) x86-64 calling convention has the first few arguments not on the stack, but in registers instead

    See http://www.x86-64.org/documentation/abi.pdf (page 20)

    Specifically:

    1. If the class is MEMORY, pass the argument on the stack.
    2. If the class is INTEGER, the next available register of the sequence %rdi, %rsi, %rdx, %rcx, %r8 and %r9 is used.
    3. If the class is SSE, the next available vector register is used, the registers are taken in the order from %xmm0 to %xmm7.
    4. If the class is SSEUP, the eightbyte is passed in the next available eightbyte chunk of the last used vector register.
    5. If the class is X87, X87UP or COMPLEX_X87, it is passed in memory.

    The INTEGER class is anything that will fit in a general purpose register, so that's what you would use for string pointers as well.

    0 讨论(0)
提交回复
热议问题