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.
Assembly calling from c and linking
Re: Assembly calling from c and linking
If you linked the code without error, the cause is usually elsewhere. did you tried not to call the asm function and do it triple fault?
Are you sure the address is correct? try objdump the executable to verifySo my code is very simple. I have loader, what is calling, with call _kmain function
Re: Assembly calling from c and linking
Hm, looks like I got it work on boch. Strange, I compiled it with dev-cpp compiler.