x64 nasm: pushing memory addresses onto the stack & call function

后端 未结 3 484
醉酒成梦
醉酒成梦 2020-12-03 09:26

I\'m pretty new to x64-assembly on the Mac, so I\'m getting confused porting some 32-bit code in 64-bit.
The program should simply print out a message via the prin

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-03 09:45

    According to the documentation for the x86 64bit instruction set http://download.intel.com/products/processor/manual/325383.pdf

    PUSH only accepts 8, 16 and 32bit immediate values (64bit registers and register addressed memory blocks are allowed though).

    PUSH msg
    

    Where msg is a 64bit immediate address will not compile as you found out.


    What calling convention is _printf defined as in your 64bit library?

    Is it expecting the parameter on the stack or using a fast-call convention where the parameters on in registers? Because x86-64 makes more general purpose registers available the fast-call convention is used more often.

提交回复
热议问题