calling-convention Questions
2
My goal is to easily extract a prototype of an arbitrary function with both the __cdecl and __stdcall calling conventions. It works fine in 32-bit. The only thing that's changing is the calling con...
Drake asked 5/5, 2016 at 17:12
2
Solved
I'm trying to figure out what actually happens in C++ if you return a struct by value from a function, vs. return a pointer to the struct. How is a struct communicated when its sent by value if a f...
Sherwood asked 15/4, 2021 at 11:28
1
Solved
In the following C code:
#include <stdio.h>
int main(void){getchar();}
It produces the following asm:
main:
push rbp
mov rbp, rsp
# no extra instruction here when header is included
call...
Battology asked 10/3, 2021 at 20:15
1
I am having some issues with writing a 64-Bit fastcall function trough shellcode, and the issue is that it seems to mess with other functions being called before and after it and despite working, a...
Fat asked 27/2, 2021 at 12:47
1
I'm learning a bit of assembly for fun (currently using NASM on Windows), and I have a question regarding the stdcall calling convention and functions with variable numbers of arguments. For exampl...
Bresee asked 23/1, 2021 at 20:10
1
In this Wikipedia article about register preservation I read that the caller function is responsible for some registers (to keep their previous data from being changed) and the callee for others.
M...
Didynamous asked 23/1, 2021 at 20:27
1
I'm trying to understand the overhead of pass object by value as a function parameter in C++/Linux/x86-64 platform.
The experimental code I used for the exploration is posted below and on godbolt.o...
Idaline asked 22/1, 2021 at 2:4
2
Solved
There are some calling conventions (e.g pascal, stdcall) but as far as I am concerned, C does use cdecl (C-declared). Each of these conventions are slightly different in the way the caller loads th...
Gamely asked 2/11, 2020 at 7:16
1
Solved
From this question, What registers are preserved through a linux x86-64 function call, it says that the following registers are saved across function calls:
r12, r13, r14, r15, rbx, rsp, rbp
So, I...
Chadbourne asked 12/9, 2020 at 21:19
3
Solved
The x86-64 System V ABI (used on everything except Windows) used to live at http://x86-64.org/documentation/abi.pdf, but that site has now fallen off the internet.
Is there a new authoritative hom...
Alexina asked 8/8, 2013 at 18:50
2
C++ has a small-size struct calling convention optimization where the compiler passes a small-size struct in function parameters as efficiently as it passes a primitive type (say, via registers). F...
Foppish asked 3/9, 2020 at 7:58
2
Solved
The C function call convention for ARM says:
Caller will pass the first 4 parameters in r0-r3.
Caller will pass any extra parameters on stack.
Caller will get the return value from r0.
I am handc...
Murmur asked 26/8, 2020 at 7:44
1
Solved
I know what the differences between __cdecl and __stdcall are, but I'm not quite sure as to why __stdcall is ignored by the compiler in x64 builds.
The functions in the following code
int __stdcall...
Ganglion asked 5/7, 2020 at 22:13
2
Solved
I am trying writing a bootloader and an extremely primitive and basic kernel to learn about bare metal coding practices and techniques. Anyways, I am writing my bootloader using NASM. My code is wo...
Extrados asked 5/7, 2020 at 5:33
3
Solved
I am trying to decompile an executable for the 68000 processor into C code, replacing the original subroutines with C functions one by one.
The problem I faced is that I don't know how to make gcc ...
Burnout asked 26/6, 2020 at 17:55
3
float __stdcall (*pFunc)(float a, float b) = (float (__stdcall *)(float,float))0x411280;
How to declare a function pointer with calling convention? The above gives me an error.
Congener asked 28/1, 2011 at 16:5
1
Solved
Very simple assembly introduction code.
Seems to compile ok through gcc -o prog1 prog1.s, then ./prog1 just skips a line and shows nothing, like waiting an input the code doesn't ask. What's wrong?...
Drier asked 5/5, 2020 at 20:26
7
Solved
I'm trying to get a deeper understanding of how the low level operations of programming languages work and especially how they interact with the OS/CPU. I've probably read every answer in every sta...
Ewers asked 1/6, 2014 at 15:27
1
Solved
I'm following an OS development tutorial. There I need to implement a function that receives address (2 bytes long) of I/O port, data (1 byte long) to be sent into that port, and sends the given da...
Indubitable asked 31/3, 2020 at 21:1
1
Solved
What is the calling convention for a syscall in a program that runs under the RISC-V pseudo-kernel (pk) or Linux?
Looking at the code generated by the riscv-gnu-toolchain the rules seem to be:
s...
Stogner asked 18/1, 2020 at 12:6
1
Solved
Consider the following example:
struct vector {
int size() const;
bool empty() const;
};
bool vector::empty() const
{
return size() == 0;
}
The generated assembly code for vector::empty (by ...
Gardie asked 7/1, 2020 at 22:22
3
Look at this assembler code. It is designed for 32 bits x86 and will be compiled by nasm
...
my_function:
pop %eax
...
ret
main:
push 0x08
call my_function
I have learned a long time ago...
Zitazitah asked 22/6, 2016 at 17:58
4
Solved
I'm watching Chandler Carruth's talk in CppCon 2019:
There are no Zero-Cost Abstractions
in it, he gives the example of how he was surprised by just how much overhead you incur by using an std::u...
Darladarlan asked 11/10, 2019 at 10:19
3
Solved
I am trying to pick up a little x86. I am compiling on a 64bit mac with gcc -S -O0.
Code in C:
printf("%d", 1);
Output:
movl $1, %esi
leaq LC0(%rip), %rdi
movl $0, %eax ; WHY?
call _printf
I...
Responsum asked 2/6, 2011 at 9:26
3
Solved
I have been doing some research into inline assembly in C and how the call stack works but I have been unable to figure out if it's at all possible to retrieve the address of a variable that is req...
Attainder asked 3/10, 2019 at 12:17
© 2022 - 2024 — McMap. All rights reserved.