[solved] my OS get restarted when jmp to PM

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Tosi
Member
Member
Posts: 255
Joined: Tue Jun 15, 2010 9:27 am
Location: Flyover State, United States
Contact:

Re: [solved] my OS get restarted when jmp to PM

Post by Tosi »

Because real mode segmentation works differently than protected mode segmentation. You loaded a GDT with a base of 0 and a limit of 4 GB which gives you a flat address space, and since you loaded to 0x0500 you have to explicitly jump to the address rather than an offset from it in protected mode.
User avatar
trinopoty
Member
Member
Posts: 87
Joined: Wed Feb 09, 2011 2:21 am
Location: Raipur, India

Re: [solved] my OS get restarted when jmp to PM

Post by trinopoty »

It works because

Code: Select all

jmp 0x08:kernel32
compiles to 'jmp 0x08:0045' when 'org 0' which is incorrect.

When org 0x0500;

Code: Select all

jmp 0x08:kernel32
compiles to 'jmp 0x08:0x0545' which is correct.
ym
Posts: 8
Joined: Thu Mar 24, 2011 2:05 am

Re: [solved] my OS get restarted when jmp to PM

Post by ym »

in my opinions,
org 0
means the variables 's address start from 0, and code offset from zero.
eg:
org 0
_start:
...
...
;offset 10
data01:

;_start should be 0, data01 should 10

org 0x7c00
means the variables 's address start from 0x7c00, and code offset from zero.
eg:
org 0x7c00
_start:
...
...
;offset 10
data01:

;_start should be 0, data01 should 0x7c10

bootsect load to 0:7c00 , if use org 0 data's addr start from 0, may read addr 0:10.
but the correct should read 0x7c10.

you can us ndisasm to disasmble your binary file , you can see the actual addr assigned.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: [solved] my OS get restarted when jmp to PM

Post by Combuster »

ym wrote:org 0x7c00
means the variables 's address start from 0x7c00, and code offset from zero.
Correction: code is also assembled to start at address 0x7c00. It makes an important difference when you use absolute jumps, like far jumps.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply