0%

arm64与x86_64对比

arm64与x86_64对比

x86_64的函数调用约定传参顺序为: rdi, rsi, rdx, rcx, r8, r9, 返回值放在rax里

arm64为: 参数1-8放在X0-X7寄存器,剩下参数从右往左依次进栈,被调用者实现栈平衡,返回值存放在X0

同样的类似于rax跟eax的关系, X0跟W0也有关系, X0

x86_64arm64
mov rdi,rsimov x0,x1
add rax,rbxadd x0, x0, #1
sub rax,rcxsub x0, x1, x2
and rax, 0xfand x0, x0, #0xf
or rax,0x9orr x0, x0, #9
xor rax,0xfeor x0, x0, #0xf

入栈指令 stp x29, x30, [sp, #0x10]

类似的有push rbp; mov rbp,rsp; sub rsp,0x10

出栈指令 ldp x29, x30, [sp, #0x10]

类似的,有pop rbp; mov rsp,rbp;

系统调用svc 0

类似的,有syscall

movk指令在传字符串的时候经常用到

1
2
3
4
5
6
instruction                    value of x0
mov x0, xzr | 0x0000000000000000
movk x0, #0x0123, lsl #48 | 0x0123000000000000
movk x0, #0x4567, lsl #32 | 0x0123456700000000
movk x0, #0x89ab, lsl #16 | 0x0123456789ab0000
movk x0, #0xcdef | 0x0123456789abcdef

本文作者:NoOne
本文地址https://noonegroup.xyz/posts/e1878b82/
版权声明:转载请注明出处!