小编Dou*_*des的帖子

从64位asm调用Printf时,params如何通过?

我正在学习再次使用汇编语言,到目前为止我遇到的唯一问题就是调用C语言.我所拥有的书是32位,而我的工作是64位.显然,调用约定存在很大差异,并且http://www.x86-64.org/documentation站点已关闭.因此,经过一些挖掘/测试,在C中编译虚拟程序并花费3天时间,我想我会发布我的发现,如果它可以帮助其他人.

RAX是否需要给出浮点数?堆栈填充"阴影空间"16或32位?这个宏用于对齐小程序的堆栈是否可以通过?我知道你可以用对齐NOP填充代码,我不确定堆栈框架.

; pf.asm compiled with 'nasm -o pf.o -f elf64 -g -F stabs'
; linked with 'gcc -o pf pf.o'
; 64-bit Bodhi (ubuntu) linux

%include "amd64_abi.mac"
[SECTION .data]
First_string:   db "First string.",10,"%s", "%d is an integer. So is %d",10
                db "Floats XMM0:%5.7f  XMM1:%.6le  XMM2:%lg",10,0  
Second_String:  db "This is the second string... %s's are not interpreted here.",10
                db " Neither are %d's nor %f's. 'Cause it is a passed value.", 10, 0
; Just a regular string …
Run Code Online (Sandbox Code Playgroud)

assembly printf x86-64 abi calling-convention

6
推荐指数
1
解决办法
5268
查看次数

标签 统计

abi ×1

assembly ×1

calling-convention ×1

printf ×1

x86-64 ×1