Page 1 of 1
far jump at protected mode
Posted: Sat Mar 28, 2009 8:58 am
by instance
Hey,
I've tried to get the system to boot, and then I loaded the gdt. However, when I try a far jump, it jumps to a nonsensical location of 0 (absolute 0)
The following is the code-
Code: Select all
lgdt [gdtr] ;pointing to gdt
mov eax, cr0
or al,1
mov cr0, eax
;At this point in protected mode
jmp 0x08:protectedmode
[bits 32]
protectedmode:
;Do stuff
mov eax,5
add eax,10
gdtr:
dw 65535
dd 0x2000
I've loaded the gdt at location 0x2000 in memory, and it is 64 kb long. When I run the code through the debugger, I see that the far jump shows-
(0) [0x00001076] 0000:0000000000001076 (unk. ctxt): jmp far 0008:107b ; ea7b100800
And then, bochs jumps to physical memory location 0
Can some1 tell me what I'm doing wrong.
Thank you
Re: far jump at protected mode
Posted: Sat Mar 28, 2009 9:11 am
by Combuster
Can some1 tell me what I'm doing wrong.
Giving us wrong information. jmp 8:label will not land you at 0 physical.
What's the next instruction to be executed after the jump? What messages does bochs give you.
Re: far jump at protected mode
Posted: Sat Mar 28, 2009 10:08 am
by xenos
Looks like a linker problem... If you have a linker map, you can look up which address is assigned to your label protectedmode.
Re: far jump at protected mode
Posted: Sat Mar 28, 2009 11:19 am
by Troy Martin
It's not a linker problem, or false information. It's that your GDT isn't even complete. there's no 0x08, the null entry isn't a dq 0, etc.
EDIT: Twenty invisible tokens says that you have no GDT whatsoever at 0x2000.
Re: far jump at protected mode
Posted: Sat Mar 28, 2009 11:28 am
by instance
Hey,
I just realized that its jumping not due to the jmp, rather, when I'm modifying the cr0 register. Here are screenshots I've taken of the debugger. You can see the physical dump of the GDT on the right pane (dumping the gdt also shows that the gdtr has been loaded properly)
EDIT:
The GDT has been loaded.... When I use the GDT dump feature of the bochs debugger, it shows alot of empty selectors, 1 code at 0x08 and 1 data at 0x10
um.... want a screenshot of that?
Re: far jump at protected mode
Posted: Sat Mar 28, 2009 11:32 am
by Troy Martin
*hands over the tokens*
Re: far jump at protected mode
Posted: Sat Mar 28, 2009 12:03 pm
by instance
Blah!! The debugger was the confusing thing.... When I go to protected mode, the asm dump just goes haywire for some reason. But I realized that by looking at IP (which remains proper) that code is getting executed properly. When I then jump (in debugger) to that location and step ahead, it seems to work like a charm..
heh.... weirdest thing ever

Re: far jump at protected mode
Posted: Sat Mar 28, 2009 5:49 pm
by Combuster
Glad that it's working.
And please do send a bug report to the devs - the debugger should just work. (In the meantime, you can still use the text debugger)