Mixing Fasm with C , need help ><
Posted: Tue Mar 25, 2008 11:40 am
Hello,
i don't know if this issue is due to a bad linking, or a mistake in my fasm code .
I tryed to link cpuid.asm with kernel.c but it doesn't work .
cpuid.asm :
kernel.c :
I use this to compile the two programs :
Who can help me please =) ?
Thanks .
PS : i'm a beginner on mixing fasm with C
i don't know if this issue is due to a bad linking, or a mistake in my fasm code .
I tryed to link cpuid.asm with kernel.c but it doesn't work .
cpuid.asm :
Code: Select all
format ELF
public get_vendor
get_vendor:
xor eax,eax ; eax <== 0 : get vendor ID
cpuid
mov [buffer], ebx
mov [buffer+4], edx
mov [buffer+8], ecx
mov eax, dword ptr buffer
ret
buffer: db " ", 0Dh, 0Ah, 0
Code: Select all
extern char* get_vendor ();
...
int kernel_main(void)
{
clrscr();
print(">CPU Vendor : ");
get_vendor(); // just for testing
print("\n");
while(1);
return(0);
}
...
Code: Select all
fasm cpuid.asm cpuid.o
gcc -ffreestanding -c kernel.c -o kernel.o
ld -e kernel_main -Ttext 0x1000 -o kernel kernel.o cpuid.o
objcopy -R .note -R .comment -S -O binary kernel kernel.bin
Thanks .
PS : i'm a beginner on mixing fasm with C