Assembly calling from c and linking
Posted: Wed May 02, 2012 11:54 am
Hi,
I want some advice, how to call assembly function correctly from C code. For C compiler I use gcc, but for assembly it is nasm. And together I link those object files with gcc linker. But all goes so bad, when I try to call assembly function from C. It can be empty function e.t.c. but in Bosch I got triple fault or hangs random, or in Virtual Box worse - hangs my whole PC Maybe it is linker issue, lost tags or something? The function even not executed. Botch won't log anything, there are nothing in log except grub logs.
So my code is very simple. I have loader, what is calling, with call _kmain function, from C and it is working wery well.
I can make seperate test assembly file with simple function:
GLOBAL _c_dummy
_c_dummy:
ret
But in C code:
extern void _c_dummy(); I have tried also c_dummy(); strange is that, that nothing changes.
c_dummy(); and at this point all hangs or triple faults.
Internet is full with instructions, how to call assembly from c, but nothing works. Even, when I compile native win32 app, i can't call assembly from that.
I want some advice, how to call assembly function correctly from C code. For C compiler I use gcc, but for assembly it is nasm. And together I link those object files with gcc linker. But all goes so bad, when I try to call assembly function from C. It can be empty function e.t.c. but in Bosch I got triple fault or hangs random, or in Virtual Box worse - hangs my whole PC Maybe it is linker issue, lost tags or something? The function even not executed. Botch won't log anything, there are nothing in log except grub logs.
So my code is very simple. I have loader, what is calling, with call _kmain function, from C and it is working wery well.
I can make seperate test assembly file with simple function:
GLOBAL _c_dummy
_c_dummy:
ret
But in C code:
extern void _c_dummy(); I have tried also c_dummy(); strange is that, that nothing changes.
c_dummy(); and at this point all hangs or triple faults.
Internet is full with instructions, how to call assembly from c, but nothing works. Even, when I compile native win32 app, i can't call assembly from that.