Stéphane thibaud wrote:
> I'm sorry for bothering y'all again... I have a little problem:
We only reply if we wanna... :)
> mov al,byte[MemoryMap_start.mapSize]
>
> The line above points to the wrong address when ran with bochs... if I
> change it to:
>
> mov al,byte[MemoryMap_start.mapSize - Code_start + 0x500] ;0x500
> is the address where my code is loaded
>
> then it does point to the right address...
>
> Both versions assemble without a problem. Is there someting I'm doing
> wrong?
Apparently!
> [ORG 0x0500] doesn't work.
"Why not?" would be a start. "org" and ds need to be "synchronized", or
the addresses Nasm calculates will be wrong. If you don't want "org
0x500" on all your code, a new section...
section code_to_move vstart=0x500
may help... (???).
Another possible issue is the way "MemoryMap_start" is declared. If it's
a "struc", "MemoryMap_start.mapsize" will evaluate to the offset from
the start of the structure, not a complete memory address - *very*
different from the same syntax in C!!! If ".mapsize" is just a local
label under MemoryMap_start, it would be the complete address -
"correct" or not would depend on "org", if any (or "vstart"), and ds.
We may need to see more of your code, if you can't find the problem.
What, if any "org" (Nasm defaults to zero, if you don't say), what's in
ds, where and how MemoryMap_start is declared, when and how the code
gets to be loaded at 0x500... A number of things need to "cooperate" for
it all to work... Lessee...
mov al,byte[MemoryMap_start.mapSize - Code_start + 0x500] ;0x500
"Code_start", assuming that it's in the obvious place, should be equal
to "org"... zero if none. If you need a specific "org"... say 0x7C00...
the (relatively "new") vstart feature may be what you want. May need
some "extras"...
org 0x7C00
section .text
xor ax, ax
mov ds, ax
....
section code_to_move follows=.text align=1 vstart=0x500
....
mov ds, ??? ;?
mov al, [MemoryMap_start.mapsize]
....
section bootsig follows=code_to_move start=0x7DFE
db 0x55, 0xAA
(or is it AA 55?) "Something like that"...
Best,
Frank


|