BxError: instruction with op1=0xff
Posted: Sun Oct 09, 2005 12:02 pm
whenever I call a C function from my C kernel code I get the following Bochs Error:
I did some checking and it turns out that whenever i call a function from kmain(), I get the error.
i can link my different files together, and it works fine, it compiles fine as well. But it screws up whenever i actually call the function...
Here's my build script, maybe something is wrong with the compiler/linker options?
gcc -ffreestanding -c kmain.c -o kmain.o
gcc -o ports.o -c ports.c
ld -e kmain -Ttext 0x100000 -o kernel.o kmain.o ports.o
ld -i -e kmain -Ttext 0x100000 -o kernel.o kmain.o ports.o
objcopy -R .note -R .comment -S -O binary kernel.o kernel.bin
amd are ports.c and kmain.c:
it crashes when I call func() from kmain()
Code: Select all
[CPU ] BxError: instruction with op1=0xff
[CPU ] mod was c0, nnn was 7, rm was 7
[CPU ] WARNING: Encountered an unknown instruction (signalling illegal instruction)
[SYS ] bx_pc_system_c::Reset(SOFTWARE) called
i can link my different files together, and it works fine, it compiles fine as well. But it screws up whenever i actually call the function...
Here's my build script, maybe something is wrong with the compiler/linker options?
gcc -ffreestanding -c kmain.c -o kmain.o
gcc -o ports.o -c ports.c
ld -e kmain -Ttext 0x100000 -o kernel.o kmain.o ports.o
ld -i -e kmain -Ttext 0x100000 -o kernel.o kmain.o ports.o
objcopy -R .note -R .comment -S -O binary kernel.o kernel.bin
amd are ports.c and kmain.c:
Code: Select all
void kmain() {
/*
* A Pointer to the VGA Text Buffer at 0xB8000
* an a lopping integer
*/
unsigned char *vgat = (unsigned char *)0xB8000;
unsigned short int i;
/* Write "Hi" in black on white */
*vgat++ = 'H';
*vgat++ = 0x0F;
*vgat++ = 'i';
*vgat++ = 0x0F;
func();
/* Clear the rest of the screen */
for(i = 2; i < 2000; i++) {
*vgat++ = 0x20;
*vgat++ = 0x0F;
}
/* Loop forever */
for(;;);
}
Code: Select all
void out(unsigned short _port, unsigned char _data) {
__asm__ __volatile__ ("out %%al, %%dx" : : "a" (_data), "d" (_port));
return;
}
unsigned char in(unsigned short _port) {
unsigned char ret;
__asm__ __volatile__ ("in %%dx, %%al" : "=a" (ret) : "d" (_port));
return ret;
}
void func() {
}