我被困了,因为当我使用pushq而不是pushl时出现段错误.如何更改此程序以输出字符串和二进制形式的寄存器?
@H_301_13@.datainput_prompt: .string "Hello,world!"printf_format: .string "%5d "printf_newline: .string "\n"size: .long 0.text.globl mainmain: pushq $input_prompt call printf movl $0,%eax ret它由GCC编制为:
@H_301_13@gcc tmp.S -o tmp解决方法 linux(和windows) x86-64 calling convention的前几个参数不在堆栈上,而是在寄存器中见http://www.x86-64.org/documentation/abi.pdf(第20页)
特别:
If the class is MEMORY,pass the argument on the stack. If the class is INTEGER,the next available register of the sequence %rdi,%rsi,%rdx,%rcx,%r8 and %r9 is used. If the class is SSE,the next available vector register is used,the registers are taken in the order from %xmm0 to %xmm7. If the class is SSEUP,the eightbyte is passed in the next available eightbyte chunk of the last used vector register. If the class is X87,X87UP or COMPLEX_X87,it is passed in memory.
INTEGER类是适合通用寄存器的任何东西,所以你也可以用它来表示字符串指针.
总结以上是内存溢出为你收集整理的Linux X86-64程序集和printf全部内容,希望文章能够帮你解决Linux X86-64程序集和printf所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)