Switching to real mode
Switching to real mode
This question is not about how to switch to real mode, per se. The process involves jumping to code that is below the 64K mark, or FFFF. I wrote a little routine to copy all the bytes from a routine inside the kernel into a location below the 64k mark but this isn't very satisfactory. I am using nasm as my compiler, and Grub as the boot loader. Is there a good way of getting code below the 64k mark? I would prefer not to use modules, and of course the code needs to be 16 bit. Copying the bytes of the routine to low memory worked, but when I switched instructions to 16 bit and tried to do a far jump to set CS to a proper 16 bit segment, I got an error from nasm similar, can't align .text section to 16 bit, I'm sorry I can't remember the exact error. Any insight would be appreciated. Thanks
You could use the following steps:
1) Write your 16-bit kernel, don't worry about grub. Lets say your kernel will be assembled to kernel.bin
2) Write a ressource file containg your kernel.bin, for example3) Write a simple 32-bit programm that has this ressource file linked in and copies the data between kernel_start and kernel_end to the correct position. After that, you could switch to real mode and jump to your 16-bit kernel.
If you have created a good makefile and your 32-bit-loader you can work with your 16-bit kernel without even thinking about 32-bit stuff
1) Write your 16-bit kernel, don't worry about grub. Lets say your kernel will be assembled to kernel.bin
2) Write a ressource file containg your kernel.bin, for example
Code: Select all
global kernel_start,kernelEnd
kernel_start:
%incbin "kernel.bin"
kernel_end:
If you have created a good makefile and your 32-bit-loader you can work with your 16-bit kernel without even thinking about 32-bit stuff