simple question, but please answer

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.
Post Reply
elias

simple question, but please answer

Post by elias »

ive seen many boot loaders with either ORG [0] or ORG [07C0], if might not be 07C0, but some other numbers, btu ims ure you guys know wat i mean. now i question is, where is the boot coded loaded to? 07C0:0000 or 0000:07C0?
dronkit

Re:simple question, but please answer

Post by dronkit »

In real mode an absolute memory address is calculated multiplying the segment value by 16 and adding the offset, so:

0000:7c00 = (0000h * 16) + 7c00h = 7c00h
07c0:0000 = (07c0h * 16) + 0h = 7c00h

they reference to the exact same memory position
Friend

Re:simple question, but please answer

Post by Friend »

Basically, there are many different segment:offset pairs that the bios might load the code to, the best idea is to simply do a jmp at the start of your boot code and this will force cs=segment for example

jmp 0x0000:Start_Boot

would force cs=0x0000 and then jump to Start_Boot, so whatever segment you want to have simply put that first and it should load cs with that value.

hope this helps.
Tom

Re:simple question, but please answer

Post by Tom »

org 0 tellsNASM that the FritzOS bootsector is at org 0 - but it's not. So I do a jump from 0x7c00:start i.e. jump from 0x7C00 to the start lable.

That's just one way to load a bootsector...
elias

Re:simple question, but please answer

Post by elias »

so i can have either
ORG [0]
or
ORG [07C0]?
as long as i jump to the first portion of code?
Tom

Re:simple question, but please answer

Post by Tom »

if you have a org 0 you have to do a "jmp 0x7C00:start"

if have a org 0x7c00 you can just do "jmp start"
elias

Re:simple question, but please answer

Post by elias »

ok thanx, now jsut one more thing. is the address 7C00 or 07C0?
Tom

Re:simple question, but please answer

Post by Tom »

I typed it in correctly "0x7C00"
grey wolf

Re:simple question, but please answer

Post by grey wolf »

the correct addresses are 0x07C0:0x0000 and 0x0000:0x7C00.

so with ORG 0x0, you need your CS to be 0x07C0 ( jmp 0x07C0:start ) and with ORG 0x7C00 your CS will be 0x0 ( jmp 0x0000:0x7C00 )
Post Reply