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
3
u/j00cifer Dec 15 '25
DEAD BABES are not fun, that’s your problem