Page 2 of 2
Re: [solved] my OS get restarted when jmp to PM
Posted: Mon Mar 07, 2011 3:18 pm
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.
Re: [solved] my OS get restarted when jmp to PM
Posted: Mon Mar 21, 2011 8:25 am
by trinopoty
It works because
compiles to 'jmp 0x08:0045' when 'org 0' which is incorrect.
When org 0x0500;
compiles to 'jmp 0x08:0x0545' which is correct.
Re: [solved] my OS get restarted when jmp to PM
Posted: Thu Mar 24, 2011 7:53 am
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.
Re: [solved] my OS get restarted when jmp to PM
Posted: Thu Mar 24, 2011 10:56 am
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.