[solved] my OS get restarted when jmp to PM
-
- 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
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
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.
Code: Select all
jmp 0x08:kernel32
When org 0x0500;
Code: Select all
jmp 0x08:kernel32
Re: [solved] my OS get restarted when jmp to PM
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.
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.
- Combuster
- 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
Correction: code is also assembled to start at address 0x7c00. It makes an important difference when you use absolute jumps, like far jumps.ym wrote:org 0x7c00
means the variables 's address start from 0x7c00, and code offset from zero.