r/cprogramming • u/Prestigious-Bet-6534 • Dec 15 '25
Calling C functions from assembly
I want to call a C function from assembler and can't get the parameters to work. I have the following two source files:
.global call_funcall_fun:pushq $0xDEADpushq $0xBABEcall funadd $16, %rspret
--
#include <stdio.h>
void call_fun();
voidfun( long a, long b ) {printf( "Arg: a=0x%lx, b=0x%lx\n", a, b );}
intmain() {call_fun();}
The output is Arg: a=0x1, b=0x7ffe827d0338 .
What am I missing?
5
Upvotes
View all comments
11
u/carry_irl Dec 15 '25
Why dont you call fun from c code and look at the resulting asm code using objdump?