Parsing Error
Posted: Tue Oct 22, 2002 9:53 am
Hi,
I have a problem with my c code, I have an asm file with this code in it
; === ASM CODE =====
[GLOBAL _KillFloppy]
; Reset and Kill Floppy Motor
_KillFloppy:
push eax
mov dx, 0x03f2
mov al, 0x00
out dx, al
pop eax
ret
then I have a c file with this code in it
; === C CODE =====
// Linked ASM Function
void KillFloppy();
// Jump to the entry point
asm("jmp _kernel_start");
// kernel entry point
void kernel_start()
{
KillFloppy();
char* video = (char*)0xb8000;
char* message = "F r i e n d O S E x a m p l e K e r n e l ";
int i;
// put the message into video memory
for ( i = 0; i < 46; i++ )
video = message;
// Hang
while( 1 )
{}
}
I am compiling and linking like this
nasm -f elf floppy.asm
gcc -c kernel.c
ld -Ttext=0x20000 kernel.o floppy.o -o kernel.exe
objcopy -O binary kernel.exe kernel.bin
but I keep getting an error from gcc saying
kernel.c: In function `kernel_start':
kernel.c:14: parse error before `char'
kernel.c:19: `i' undeclared (first use in this function)
kernel.c:19: (Each undeclared identifier is reported only once
kernel.c:19: for each function it appears in.)
kernel.c:20: `video' undeclared (first use in this function)
kernel.c:20: `message' undeclared (first use in this function)
any ideas what is wrong?
thanks.
I have a problem with my c code, I have an asm file with this code in it
; === ASM CODE =====
[GLOBAL _KillFloppy]
; Reset and Kill Floppy Motor
_KillFloppy:
push eax
mov dx, 0x03f2
mov al, 0x00
out dx, al
pop eax
ret
then I have a c file with this code in it
; === C CODE =====
// Linked ASM Function
void KillFloppy();
// Jump to the entry point
asm("jmp _kernel_start");
// kernel entry point
void kernel_start()
{
KillFloppy();
char* video = (char*)0xb8000;
char* message = "F r i e n d O S E x a m p l e K e r n e l ";
int i;
// put the message into video memory
for ( i = 0; i < 46; i++ )
video = message;
// Hang
while( 1 )
{}
}
I am compiling and linking like this
nasm -f elf floppy.asm
gcc -c kernel.c
ld -Ttext=0x20000 kernel.o floppy.o -o kernel.exe
objcopy -O binary kernel.exe kernel.bin
but I keep getting an error from gcc saying
kernel.c: In function `kernel_start':
kernel.c:14: parse error before `char'
kernel.c:19: `i' undeclared (first use in this function)
kernel.c:19: (Each undeclared identifier is reported only once
kernel.c:19: for each function it appears in.)
kernel.c:20: `video' undeclared (first use in this function)
kernel.c:20: `message' undeclared (first use in this function)
any ideas what is wrong?
thanks.