Author Topic: set org twice?  (Read 8965 times)

nobody

  • Guest
set org twice?
« on: February 11, 2008, 09:53:02 PM »
Hi

I want to set the org "instruction" twice because in one (binary) file. The first is at the top of it, where i have code and the second at the bottom, where I have my variables and all other data...
The hole data section will be mapped at an other place while the code is executing...So I want the first "org" at the begin of the code to relativize all labels in the code section like jumps.
But when I access some variables or other stuff in my data section, I want, that this labels are added to the start adress where the data is mapped.

I dont want to split up the code. I search a solution which is as simple as possible.

Thx Noooooooooos

nobody

  • Guest
Re: set org twice?
« Reply #1 on: February 11, 2008, 10:23:19 PM »
Only one origin per file, in Nasm. If you want the virtual address to differ from file-offset (plus org), you can use "vstart"...

Best,
Frank


org 100h

section .text

mov si, file_datastart
mov di, 1000h
mov cx, dataend - datastart
rep movsb

mov ah, 9
mov dx, msg
int 21h

ret

file_datastart:
section data_to_mov vstart=1000h align=1

datastart:
msg db "hello from 1000h$"
dataend:

nobody

  • Guest
Re: set org twice?
« Reply #2 on: February 13, 2008, 05:35:22 PM »
So should file_datastart have a value below 0x1000 and datastart exact 0x1000?
And why is the align "instruction" necessary?

Thx
Noooooooooos

nobody

  • Guest
Re: set org twice?
« Reply #3 on: February 13, 2008, 09:09:44 PM »
The align "property" or "attribute" of a section would add zeros to pad up to the specified alignment - default is dword. Since I didn't want any padding, I set align=1...

The 0x1000 is purely arbitrary - set it to where you plan to move/map the section. If this is real mode code, you may want "vstart=0", in some other segment...

Best,
Frank