flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Why get_relative_offset won't cooperate?

Author
Thread Post new topic Reply to topic
beppe85



Joined: 23 Oct 2004
Posts: 181
beppe85
Hi, people!

I'm trying to get a relative offset for an operand. I can get absolute address with get_dword_value, that works okay even with forward references. But how could I get the current PC?

Privalov, can you also explain the next_pass_needed symbol? I mean, what can set it to TRUE, and when we need to bother with it, when parsing an instruction.

Thanks in advance.

_________________
"I assemble, therefore I am"

If you got some spare time, visit my blog: http://www.beppe.theblog.com.br/ and sign my guestmap
Post 09 Feb 2005, 07:11
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
get_relative_offset calculates the (address-$) value, it does it by adding the $ and substraction operation symbols at the end of expression calculation (the fasm's expression calculator works in RPN). The value of $ symbol itself is calculated internally by expression calculator at "current_offset_label" and it does it by substracting the 64-bit [org_origin] variable from the current code generation pointer, zero-extended to 64 bits.

When writing an instruction handler, you usually don't have to bother with [next_pass_needed] variable, the routines like "get_dword_value" do it for you. However I already posted once the detailed description of how fasm determines when the next pass is needed, look here:
http://board.flatassembler.net/topic.php?t=1774
Post 09 Feb 2005, 11:48
View user's profile Send private message Visit poster's website Reply with quote
beppe85



Joined: 23 Oct 2004
Posts: 181
beppe85
Very thank you! I'll re-read how jmp/jcc are implemented to see what I made wrong.

And I'll read the link you have passed, I think it would be very instructive.

_________________
"I assemble, therefore I am"

If you got some spare time, visit my blog: http://www.beppe.theblog.com.br/ and sign my guestmap
Post 09 Feb 2005, 18:12
View user's profile Send private message 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.