calling-convention

Why does eax contain the number of vector parameters?

a 夏天 提交于 2020-12-23 11:13:01
问题 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

How to get an argument from stack in x64 assembly?

旧城冷巷雨未停 提交于 2020-12-15 06:22:05
问题 I'm trying to write a procedure in x64 assembly. I'm calling it in a main program that is written in C++. I'm passing several parameters. I know that first 4 will be in specific registers and the rest of them (should be) on stack. What's more, I read that before taking 5th argument from the stack, I should substract 40 from RSP. And at the begining it worked. Later I needed to check the address of sth so I did it by: cout and &. But then, taking 5th argument from stack didn't work and I have

Function parameters transferred in registers on 64bit OS?

送分小仙女□ 提交于 2020-11-30 12:24:04
问题 I am reading one of Agner Fog's manuals and as an advantage for 64 bit Operating Systems (over 32 bit) he says: Function parameters are transferred in registers rather than on the stack. This makes function calls more efficient. Is he saying the stack is not used for passing function parameters (64bit OS) at all??? 回答1: Yes, that's what he's saying, but it's not quite accurate. The stack may be used, but only if your function has a lot of parameters (or you write code that forces a spill). If

Function parameters transferred in registers on 64bit OS?

☆樱花仙子☆ 提交于 2020-11-30 12:21:14
问题 I am reading one of Agner Fog's manuals and as an advantage for 64 bit Operating Systems (over 32 bit) he says: Function parameters are transferred in registers rather than on the stack. This makes function calls more efficient. Is he saying the stack is not used for passing function parameters (64bit OS) at all??? 回答1: Yes, that's what he's saying, but it's not quite accurate. The stack may be used, but only if your function has a lot of parameters (or you write code that forces a spill). If

Function parameters transferred in registers on 64bit OS?

梦想与她 提交于 2020-11-30 12:21:10
问题 I am reading one of Agner Fog's manuals and as an advantage for 64 bit Operating Systems (over 32 bit) he says: Function parameters are transferred in registers rather than on the stack. This makes function calls more efficient. Is he saying the stack is not used for passing function parameters (64bit OS) at all??? 回答1: Yes, that's what he's saying, but it's not quite accurate. The stack may be used, but only if your function has a lot of parameters (or you write code that forces a spill). If

Function parameters transferred in registers on 64bit OS?

ⅰ亾dé卋堺 提交于 2020-11-30 12:19:21
问题 I am reading one of Agner Fog's manuals and as an advantage for 64 bit Operating Systems (over 32 bit) he says: Function parameters are transferred in registers rather than on the stack. This makes function calls more efficient. Is he saying the stack is not used for passing function parameters (64bit OS) at all??? 回答1: Yes, that's what he's saying, but it's not quite accurate. The stack may be used, but only if your function has a lot of parameters (or you write code that forces a spill). If

Why does the x86-64 System V calling convention pass args in registers instead of just the stack?

谁说胖子不能爱 提交于 2020-11-29 03:52:52
问题 Why is it that 32-bit C pushes all function arguments straight onto the stack while 64-bit C puts the first 6 arguments into registers and the rest on the stack? So the 32-bit stack would look like: ... arg2 arg1 return address old %rbp While the 64-bit stack would look like: ... arg8 arg7 return address old %rbp arg6 arg5 arg4 arg3 arg2 arg1 So why does 64-bit C do this? Isn't it much easier to just push everything to the stack instead of put the first 6 arguments in registers just to move

What's the best way to remember the x86-64 System V arg register order?

一世执手 提交于 2020-11-25 03:41:39
问题 I often forget the registers that I need to use for each argument in a syscall, and everytime I forget I just visit this question. The right order for integer/pointer args to x86_64 user-space function calls is: %rdi , %rsi , %rdx , %rcx , %r8 and %r9 . (with variadic functions taking AL = the number of FP args, up to 8) Or for system calls, %rax (syscall call number), and same args except %r10 instead of %rcx . What's the best way to remember these registers instead of google this question