As described by Tim, you can do it via modifying the base of the GDT entries so that when "fake" addresses are added, they wrap around to physical addresses.
I've not quite gotten that far though yet, I'm just currently using the default GDT that GRUB hands me, compare a value in my data segment to a known good value, and trying to jump to a function within my kernel.
My kernel is linked so everything is offsetted to 0xC0000000. GRUB loads the kernel to 0x100000. So when I jump to a location, I need to somehow subtract 0xBFF00000 from the final location's address(as the GDT base isn't setup yet so that stuff will wrap around).
My current code for this is:
Code: Select all
[bits 32]
[section .text]
start:
; first test
mov eax, [magic-0xBFF00000]
cmp eax, 0x1234ABCD
je fine-0xBFF00000 ; this a second test too actually
; comparing didn't end up correct, display a blinking "D"
mov word [0B8000h],9F44h
cli
hlt
fine:
cli
hlt
[section .data]
magic:
dd 0x1234ABCD
boiler.asm:7: error: short jump is out of range
Changing je fine-0xBFF00000 too je FAR fine-0xBFF00000 simply makes NASM complain of an incorrect use of the FAR operator.
I'm sure the solution to this is obvious, but I've not touched ASM for about 5 months, so I'm kinda rusty.
Any help is appreciated,
K.J.