calling-convention Questions

1

Solved

If we look at a few modern calling conventions, like x86-64 SysV style or AArch64 style (document aapcs64.pdf titled "Procedure Call Standard for the Arm® 64-bit Architecture"), we see ex...
Stentorian asked 23/10 at 10:57

3

Solved

I find that in RISC-V, ra is caller saved, in MIPS, ra is callee, which means in RISC-V callee can directly change the value in ra without save, but since ra has changed, how callee return back to ...
Breakneck asked 11/1, 2020 at 9:52

2

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 func...
Balloon asked 14/9, 2020 at 21:21

1

Solved

I've stumbled across an oddity in MSVCs codegen, regarding structures that are used as return-values. Consider the following code (live demo here): struct Result { uint64_t value; }; Result makeR...
Crapulous asked 28/3 at 14:56

2

When compiling below code: global main extern printf, scanf section .data msg: db "Enter a number: ",10,0 format:db "%d",0 section .bss number resb 4 section .text main: mov rdi, msg mov a...
Weidman asked 27/6, 2018 at 20:13

10

Solved

I've written function 'A' that will call one of a number of other functions. To save re-writing function 'A', I'd like to pass the function to be called as a parameter of function 'A'. For example:...
Sedulous asked 2/3, 2014 at 15:37

1

Solved

In Raku: when I create an object with a CALL-ME method, I would like to use the < ... > syntax for the signature instead of ( '...' ) when ... is a Str. In the documentation, there is an exam...
Cissoid asked 12/11, 2023 at 16:24

20

We recently attempted to break apart some of our Visual Studio projects into libraries, and everything seemed to compile and build fine in a test project with one of the library projects as a depen...
Tove asked 27/9, 2008 at 0:45

1

Take this simple example: struct has_destruct_t { int a; ~has_destruct_t() {} }; struct no_destruct_t { int a; }; int bar_no_destruct(no_destruct_t); int foo_no_destruct(void) { no_destruct_...

3

I want to print a float value with printf global main extern printf section .data string: db `%f\n`, 0 section .bss rs: resq 1 [...] movq xmm0, [rs] mov rdi, string mov rax, 0 call print...
Waiver asked 15/12, 2013 at 12:59

3

Solved

How does stack alignment work in ASMx64? When do you need to align the stack before a function call and how much do you need to subtract? I didn't understand what was the purpose of it. I know ther...
Magnetohydrodynamics asked 7/11, 2020 at 15:0

3

Solved

CPU registers can be classified as volatile and non-volatile by calling convension, how does does the meaning of word volatile implies the classification?
Affusion asked 14/8, 2015 at 4:11

1

Solved

I'm generating LLVM IR for JIT purposes, and I notice that LLVM's calling conventions don't seem to match the C calling conventions when aggregate values are involved. For instance, when I declare ...
Repine asked 11/9, 2016 at 16:4

6

Solved

I'm having some trouble understanding the difference between caller and callee saved registers and when to use what. I am using the MSP430 : procedure: mov.w #0,R7 mov.w #0,R6 add.w R6,R7 in...
Night asked 13/2, 2012 at 21:51

4

Solved

My understanding is that for the cdecl calling convention, the caller is responsible for cleaning the stack and therefore can pass any number of arguments. On the other hand, stdcall callees clean ...
Byer asked 20/7, 2022 at 12:47

2

The reason for stack overflow is because stack space runs out, but what if functions have no parameters so that no data has to be pushed onto the stack? That still leaves pushing the "return" addre...
Cheiro asked 15/3, 2014 at 12:31

6

Solved

It's been a while since I last coded arm assembler and I'm a little rusty on the details. If I call a C function from arm, I only have to worry about saving r0-r3 and lr, right? If the C function ...
Marchant asked 4/11, 2008 at 10:16

0

I am new to programming with the AVX/AVX2 instructions and am trying to optimize the speed of my code. Following the older expectation that passing by reference is faster I wrote my code to do that...
Tantalous asked 14/5, 2022 at 15:41

2

Solved

So I've been practicing to write simple subroutines in FASMW using the CDECL and STDCALL calling conventions and it got me wondering about what the printf function in C would be using. Also, a defi...
Beshore asked 13/5, 2022 at 12:15

1

Solved

I am following the book "Beginning x64 Assembly Programming", in Linux 64 system. I am using NASM and gcc. In the chapter about floating point operations the book specifies the below code...
Welcy asked 23/4, 2022 at 18:16

2

Solved

I'm porting some AArch64/ARM64/Apple Silicon assembly code from Linux to macOS. This code uses all 31 available registers (stack pointer doesn't count) to avoid almost all cases of spilling; the Li...
Tamelatameless asked 17/2, 2022 at 4:28

0

Due to the 16 bytes alignment by default, does this imply the assertion in my question ?
Cadent asked 2/12, 2021 at 1:9

8

Solved

Yes, I know that "cdecl" is the name of a prominent calling convention, so please don't explain calling conventions to me. What I'm asking is what the abbreviation (?) "cdecl" actually stands for. ...
Howie asked 13/2, 2011 at 21:0

2

Using assembly x86_64 in MASM, there are some registers whose value must be saved before using; they must be pushed to the stack. These are: RBP, RBX, RSP, R12, R13, R14, and R15. Taking for ...
Earthen asked 2/10, 2021 at 19:6

2

It is said that returning an oversized struct by value (as opposed to returning a pointer to the struct) from a function incurs unnecessary copy on the stack. By "oversized", I mean a str...
Cartilaginous asked 3/6, 2021 at 15:55

© 2022 - 2024 — McMap. All rights reserved.