Calling ASM functions from C
Posted: Mon Jul 15, 2002 11:00 pm
OK, here is the situation. My bootloader sets up a pmode stack, loads in a GDT and jumps to my kernel code, which is currently located at 0x10000 physical.
Then the kernel sets up a new GDT. Works fine too. But, I have an asm function called _load_gs.
The C declaration is "extern void load_gs(unsigned int newfs);
asm code is as follows:
_load_gs:
push ebp
mov ebp,esp
xor eax,eax
mov eax, [ds:ebp+4] ; 1st param passed by C according to all docs I have
mov gs,eax
pop ebp
retn
Can anybody tell me what I could possibly be doing wrong?!? From what a routine I wrote tells me, eax contains gibberish, and not the 1st parameter passed by C. BTW, ds and ss are the same.
Thanks for any help
Hunter Seeker
Then the kernel sets up a new GDT. Works fine too. But, I have an asm function called _load_gs.
The C declaration is "extern void load_gs(unsigned int newfs);
asm code is as follows:
_load_gs:
push ebp
mov ebp,esp
xor eax,eax
mov eax, [ds:ebp+4] ; 1st param passed by C according to all docs I have
mov gs,eax
pop ebp
retn
Can anybody tell me what I could possibly be doing wrong?!? From what a routine I wrote tells me, eax contains gibberish, and not the 1st parameter passed by C. BTW, ds and ss are the same.
Thanks for any help
Hunter Seeker