org 0x7c00
org 0x7c00
when you say org 0x7c00 does the address refer to a linear address or the offset of an address? i think it has to refer to the linear.....anyone know for sure..?
Re:org 0x7c00
The ORG directive in an assembly source file specifies the offset from the start of a segment. The assembler doesn't know anything about where segments are located.
The number in the ORG directive is also a linear address wihtin a segment if the segment starts at address zero.
The number in the ORG directive is also a linear address wihtin a segment if the segment starts at address zero.
Re:org 0x7c00
when the pc boots up what is the initial value of cs? wouldnt it have to be 0?
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:org 0x7c00
unfortunately, the early PC cloners weren't clear at this: it was just mentionned that the code will be loaded by the bios at physical address 0x7C00, but the exact CS:IP combination to be used was never clearly defined.
Potentially, any combination that fits CS*16+IP=0x7C00 would be valid (such as CS=0x700, IP=0xC00), but in practice only two are used: 0000:7C00 anc 07C0:0000.
So the only wise way to work is to *force* the combination you want by the mean of a far jump as the first instruction:
or
Potentially, any combination that fits CS*16+IP=0x7C00 would be valid (such as CS=0x700, IP=0xC00), but in practice only two are used: 0000:7C00 anc 07C0:0000.
So the only wise way to work is to *force* the combination you want by the mean of a far jump as the first instruction:
Code: Select all
[ORG 0]
jmp far 07c0h:label
label:
Code: Select all
[ORG 7C00h]
jmp far 0000:label
label:
Re:org 0x7c00
i was thinking about something like this:
shouldnt something like this work?
Code: Select all
;(booter)
[bits 16]
[org 0x00]
jump:
mov ax, 0x7c00
add ax, boot
jmp far 0x00:ax
boot:
code
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:org 0x7c00
in fact, there's no such thing as "jmp register-value" ... but you're right on one point: using jmp 0x7c00:0 wouldn't have worked either (just creates an endless loop). Patched my previous code ...
Re:org 0x7c00
this works...
Code: Select all
;(booter)
[bits 16]
[org 0x00]
jmp jump
myvar dw 0x7c00+boot
jump:
jmp 0x00:myvar
boot:
mov ax, cs
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov sp, 0x700
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:org 0x7c00
1. as your variable's content is constant, while not putting it directly in the jump statement ?
2. are you sure it's really correct ? you say the assembler the sector will start at offset 0 and then you jump to offset 7C00 ... weird, weird, imho.
Code: Select all
jmp 0x00: 0x7c00+boot
Re:org 0x7c00
I think what Pype.Clicker means is:
This way you get the assembler to add the 7C00 for you. If you keep the [org 0x00], you will have problems when you start to use variables.
Code: Select all
;(booter)
[bits 16]
[org 0x7c00]
jmp 0x00:boot
boot:
mov ax, cs
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov sp, 0x700