Skip to main content

Questions tagged [calling-convention]

A calling convention refers to the way a function transmits parameters to a called function and receives a return value from it.

calling-convention
3 votes
0 answers
51 views

How to pass arguments to a windows syscall in NASM assembly? [duplicate]

I am learning how to implement direct system calls using nasm assembly and c code, I have created a funcs.asm that contains section .text global NtOpenProcess NtOpenProcess: mov rax, 26h ...
RAT's user avatar
  • 199
0 votes
1 answer
36 views

x86 NASM Crash - Iterate over string

How to iterate over individual characters of a string in x86 assembly and print them? global _main ; declare _main entry point extern _printf ; extern method section ....
OutOfBrainExcepction's user avatar
-1 votes
0 answers
53 views

Why does gcc not allocate space for local variable in this example? [duplicate]

This is the C code I compiled with gcc - #include <stdio.h> #include <stdlib.h> int sum(int arr[20]) { int s = 0; for (int i = 0; i < 20; i++) s += arr[i]; return s;...
Irtiaz Kabir's user avatar
2 votes
2 answers
74 views

tail call optimization with arguments on stack and callee with more arguments than caller

I have been writing a compiler and have discussed this situation with a colleague. In the most general case, suppose you have your arguments on the stack (once argument registers are exhausted). If ...
user129393192's user avatar
0 votes
1 answer
88 views

Difference between calling convention and order of evaluation of function arguments in C? [duplicate]

The following code yields different outputs on different compilers; #include <stdio.h> void fun(int x, int y, int z) /* function definition */ { printf("%d %d %d \n", x, y, z); /...
Quorthon's user avatar
1 vote
0 answers
36 views

Stack alignment in cdecl

The x86 calling conventions page in wikipedia mentions the alignment of stack in cdecl calling convention: Stack aligned on 16-byte boundary due to a bug. What is that? a bug?
jinreal's user avatar
  • 1,555
2 votes
1 answer
51 views

LDS is causing an infinite loop while LES is working perfectly

This is my only code code.asm. I am executing this function from a .c file. But with this simple code, using lds instead of les causes an infinite loop... _COD SEGMENT BYTE PUBLIC 'CODE' ASSUME CS:...
pequeñaluna's user avatar
1 vote
0 answers
44 views

Change calling convention in compiler-explorer gcc x86-64

Out of curiosity, I wanted to understand the different calling conventions like cdecl or fastcall. So I look at the documentation from gcc and it seems we can use the cdecl or fastcall attributes in ...
roi_saumon's user avatar
6 votes
1 answer
241 views

Why does MSVC never return struct in RAX for member-functions?

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 ...
Juliean's user avatar
  • 1,077
2 votes
2 answers
91 views

Ensuring x64 compliance of custom ASM-function in clang-cl

For my custom compiled native x64 JIT-code, I have certain instrinsic functions. A lot of them are just called from my code, thus I will generate with my own compiler. Some of them however are ...
Juliean's user avatar
  • 1,077
3 votes
1 answer
189 views

Calling Rust functions from inline assembly and calling conventions

I'm working on some code that has be assembly within my Rust project. A coworker and I are discussing the calling conventions and I have been having trouble finding definitive resources for this. As I ...
Derek C.'s user avatar
  • 1,000
0 votes
1 answer
25 views

assembly code have a mistake Run-Time Check Failure

I have a Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function ...
Zarzd's user avatar
  • 11
2 votes
0 answers
136 views

Force GCC to return floats in integer registers

When targeting the x86(-32) architecture, GCC provides a way to completely disable generation of x87 FPU instructions and instead generate calls to library functions which do floating-point math in ...
DarkAtom's user avatar
  • 3,076
1 vote
0 answers
49 views

Preventing Arm Neon d8-d15 spilling in a function

I'm having a function to be called through function pointer, which uses all the 32 Arm Neon registers. The calling convention requires to spill and restore the bottom part of the registers d8-d15, ...
Aki Suihkonen's user avatar
5 votes
1 answer
135 views

Type-traits for handling structs in Windows x64 calling convention

I'm trying to figure out how to detect if a certain c++-pass can be passed directly in a register, or whether an address has to be passed in the x64-calling convention. For reference, I have my own ...
Juliean's user avatar
  • 1,077

15 30 50 per page
1
2 3 4 5
73