calling-convention

ARM AArch64 stack management

﹥>﹥吖頭↗ 提交于 2021-02-05 08:06:53
问题 Is there no ability to have a 64 bit stack for ARMv8? I understand there is no push and pop instructions on AArch64 so is stack management left to AArch32 for parameter passing and such? How can we pass the 48 bit addresses? I'm overall confused how function calls will work when operating in AArch64. 回答1: Much like in 32-bit * , SP is a valid base register for any load/store instruction, so the mechanics aren't all that different. What is different is that SP is no longer a general-purpose

ARM AArch64 stack management

[亡魂溺海] 提交于 2021-02-05 08:06:25
问题 Is there no ability to have a 64 bit stack for ARMv8? I understand there is no push and pop instructions on AArch64 so is stack management left to AArch32 for parameter passing and such? How can we pass the 48 bit addresses? I'm overall confused how function calls will work when operating in AArch64. 回答1: Much like in 32-bit * , SP is a valid base register for any load/store instruction, so the mechanics aren't all that different. What is different is that SP is no longer a general-purpose

NASM should I pop function argument after calling a function?

女生的网名这么多〃 提交于 2021-02-05 06:51:29
问题 Let's say I have a nasm function like this: inc: mov rax,[rsp + 8] add [rax],BYTE 1 ret And I am calling this function like this: push some_var call inc I want to pass an argument to the function through the stack, so I push some_var and then call my function. In the function my item is second on the stack so I take it like: mov rax,[rsp+8] My question is: after calling function should I somehow pop my argument from the stack? If so, can I somehow delete it from the stack, I mean pop it, but

When to use a certain calling convention

二次信任 提交于 2021-02-05 06:44:05
问题 Are there any guidelines in x86-64 for when a function should abide by the System V guidelines and when it doesn't matter? This is in response to an answer here which mentions using other calling conventions for simplifying an internal/local function. # gcc 32-bit regparm calling convention is_even: # input in RAX, bool return value in AL not %eax # 2 bytes and $1, %al # 2 bytes ret # custom calling convention: is_even: # input in RDI # returns in ZF. ZF=1 means even test $1, %dil # 4 bytes.

Calling sprintf in x64 assembly

老子叫甜甜 提交于 2021-01-29 19:18:22
问题 It seems that I can't call sprintf() correctly in assembly. When I try to dprintf() my buffer that should now be formatted, all I get is: (null) and a segmentation fault. When running lldb with my program, strlen() is the reason of the fail as it can't find a \0 in my buffer. Here's my code: mov rdi, buff mov rsi, 0 mov rdx, 17 call memset lea rsi, [rel n_head] mov rdx, rax call sprintf mov rdx, rdi lea rsi, [rel fmt] mov rdi, 1 call dprintf ... section .data n_head: db "Low battery: %d%%", 0

Passing parameters to a function — push or registers [duplicate]

半腔热情 提交于 2021-01-29 05:14:00
问题 This question already has answers here : What are the calling conventions for UNIX & Linux system calls (and user-space functions) on i386 and x86-64 (4 answers) Where is the x86-64 System V ABI documented? (3 answers) Why does Windows64 use a different calling convention from all other OSes on x86-64? (4 answers) Closed 5 months ago . I want to write a function that does something like: def addme(x, y): return x + y I know there is already an instruction for this, but I'm practicing how to

HasThis & ExplicitThis calling conventions

时光毁灭记忆、已成空白 提交于 2021-01-27 18:40:35
问题 I come across HasThis and ExplicitThis calling conventions on .NET Framework reference source, and thus I begin to wonder: When are they set by compiler? Are there any examples using this combination of calling conventions (in "real world" managed program)? MSDN has described them as: ExplicitThis Specifies that the signature is a function-pointer signature, representing a call to an instance or virtual method (not a static method). If ExplicitThis is set, HasThis must also be set. The first

Why does eax contain the number of vector parameters?

时光怂恿深爱的人放手 提交于 2020-12-23 11:15:52
问题 Why does al contain the number of vector parameters in assembly? Why are vector parameters any different from normal parameters for the callee? 回答1: The value is used for optimization as stated in the ABI document The prologue should use %al to avoid unnecessarily saving XMM registers. This is especially important for integer only programs to prevent the initialization of the XMM unit. 3.5.7 Variable Argument Lists - The Register Save Area. System V Application Binary Interface version 1.0

Why does eax contain the number of vector parameters?

假装没事ソ 提交于 2020-12-23 11:14:26
问题 Why does al contain the number of vector parameters in assembly? Why are vector parameters any different from normal parameters for the callee? 回答1: The value is used for optimization as stated in the ABI document The prologue should use %al to avoid unnecessarily saving XMM registers. This is especially important for integer only programs to prevent the initialization of the XMM unit. 3.5.7 Variable Argument Lists - The Register Save Area. System V Application Binary Interface version 1.0

Why does eax contain the number of vector parameters?

余生长醉 提交于 2020-12-23 11:13:42
问题 Why does al contain the number of vector parameters in assembly? Why are vector parameters any different from normal parameters for the callee? 回答1: The value is used for optimization as stated in the ABI document The prologue should use %al to avoid unnecessarily saving XMM registers. This is especially important for integer only programs to prevent the initialization of the XMM unit. 3.5.7 Variable Argument Lists - The Register Save Area. System V Application Binary Interface version 1.0