Octocontrabass wrote:
TheGameMaker90 wrote:
Interesting... How would I do that? C generates no less than 32-bit code I thought.
The GCC manual says "-m16". The code still requires a 32-bit CPU, but it will run when that CPU is in 16-bit mode. The rest of the ABI is the same as in 32-bit mode, including the requirement for CS, DS, ES, and SS to all have the same base.
TheGameMaker90 wrote:
And isn't that the default way of doing it? Write a bootloader, switch to 32 bit protected mode, then call kmain or your kernel's entry point.
Yes, but if you want to call a BIOS function, you have to either do it before you switch to 32-bit protected mode or switch back to real mode. My suggestion falls in the "or switch back to real mode" category.
Ah, okay. So I tried what you said about the -m16 and it didn't complain or anything, but I'm not seeing the 'X' I want to print as a test to see if it's working. Should I create a git repo for this? Maybe it would be easier to see what I have so far, especially since this isn't official.
Basically in my boot.S I have the following:
Code:
boot.S:
...
.globl initialize_terminal
_start:
call boot_main
ret
initialize_terminal:
mov $'X', %al
mov $0x0e, %ah
int $0x10
ret
...
Code:
bootloader.c:
extern void initialize_terminal(void);
void boot_main(void)
{
initialize_terminal();
}
For my linker I used:
i686-elf-ld -Ttext 0x7C00 --oformat=binary boot.o bootloader.o -o boot.bin
Ideally, to make sure it's working I expect to see an X in there, but just an empty terminal
Edit:
So what should be stored in those registers? I tried "xor %ax, %ax" to zero them out, then moved %ax to all of them, then I tried 0x10. I'm admittedly clueless here...
neon wrote:
Hi,
If interested... I can provide a copy of the services method used in our boot loader if it'll be helpful for ideas as it does drop to real mode to call the BIOS... I am aware of some forum members using virtual 8086 mode instead so that may also be an option if you want an even bigger challenge.
Thank you, I'd appreciate that. Perhaps poking around will give me additional insight.