flat assembler
Message board for the users of flat assembler.

Index > Main > How to use align directive?

Author
Thread Post new topic Reply to topic
LiuJunfeng



Joined: 28 Nov 2003
Posts: 48
Location: China
LiuJunfeng 23 Mar 2004, 18:08
What's the meaning of its parameter?
Does org affect align's behavior?
How can I align code or data to file address 200h,400h,600h and so on?

//The fasm manual doesn't explain this clearly.
Post 23 Mar 2004, 18:08
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 23 Mar 2004, 19:34
Yes, the "org" affects "align", as the alignment is always done relative to $ address, which is affected by "org" - the alignment is done for the address in memory, not the pointer in file. Also "align" works only with powers of two, if you need some other alignments, use the old alignment macros.
Post 23 Mar 2004, 19:34
View user's profile Send private message Visit poster's website Reply with quote
LiuJunfeng



Joined: 28 Nov 2003
Posts: 48
Location: China
LiuJunfeng 23 Mar 2004, 22:50
I find that
Code:
rb offset_to_align - $    
works well.
But since $ is relative to org, what if I want to get the absolute offset?


Last edited by LiuJunfeng on 24 Mar 2004, 12:41; edited 1 time in total
Post 23 Mar 2004, 22:50
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 23 Mar 2004, 22:54
What do you mean by "absolute offset"?
Post 23 Mar 2004, 22:54
View user's profile Send private message Visit poster's website Reply with quote
LiuJunfeng



Joined: 28 Nov 2003
Posts: 48
Location: China
LiuJunfeng 24 Mar 2004, 03:44
If you don't use any org directive, then $'s value equal to "absolute offset".

If many org directives are used, then $'s value is relative.
Post 24 Mar 2004, 03:44
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 24 Mar 2004, 05:19
Hi Liu. The word "relative" have several meanings in English language.
Quote:
Yes, the "org" affects "align", as the alignment is always done relative to $ address


Privalov used it in the meaning: "Align changes the $ value and org changes this value too."

"org" directive simply changes the value of "$" internal variable. "align" also changes the value of "$" internal variable, but in another manner.

Regards.
Post 24 Mar 2004, 05:19
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 24 Mar 2004, 10:30
To be more precise: "org" directive does not change value of "$" directly, it changes the addressing origin, which is used to calculate "$" - which is always obtained by substracting that origin from the current pointer in output code. And "align", like any instruction coded or data directives, put some new bytes into output, therefore modifying the current pointer, but not the addressing origin, which can be altered only with "org". And as the numer of byte that "align" puts into the output is dependent on the "$" value (as the "align" pads current pointer up to the nearest aligned "$" value), it's this way dependent on the addessing origin, too.
Post 24 Mar 2004, 10:30
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.