flat assembler
Message board for the users of flat assembler.

Index > Main > The '$' operator...

Author
Thread Post new topic Reply to topic
milind



Joined: 15 Feb 2004
Posts: 33
milind 30 Mar 2004, 20:49
I have the confusion regarding the dollar operator as connected with virtual. If we use the virtual block in a program then from the $ operator we can find the size of it. Does this mean that if we use a virtual block we cannot use the $ operator in reference to the actual offsets in the output file?
The dollar operator is used like this in the file STDCALL.INC
Please clarify, anybody.
Post 30 Mar 2004, 20:49
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 30 Mar 2004, 21:03
The $ operator is never actually related to the offset in output file. It's the value of assumed address at which currently generated code will be loaded into memory. You can adjust this assumed address with "org" directive, for example at the beginning of .com program you put the "org 100h" directive and just after it the value of $ is 100h. And when you write a boot sector, you use "org 7C00h", and then $ points to 7C00h and above.
The "virtual" directive marks a special block of code, which can have the different "org" setting (you do it by putting the "at" operator and address after "virtual" word) and the code from such block is not put into the output file. So after you end the virtual block, assembler goes back to the offset at which it was before starting that block, and restores the "org" setting.
In case of "virtual at 0" directive, the $ address is zero-based, so it can be used as the size of the already generated code inside the virtual block. In the same way when you've got the source with "org 0" setting at the very beginning (which the same as default setting for the binary output, in case when you don't use any "org" and "format" directives at all), the $ value is the same as the offset in the output file, but this is the only case.
Post 30 Mar 2004, 21:03
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.