flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > How to get the address in something passed?

Goto page Previous  1, 2, 3
Author
Thread Post new topic Reply to topic
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
baldr wrote:
Azu,

OK, how do you decide whether arbitrary expression is relocatable?


If the expression is between the start and end of the block of code and isn't relative (like jmp or call with imm) and references an address that is also within it, or is relative and references an address outside of it, or if the expression is outside of it (in virtual directive) and references an address inside it, then I subtract the start of the code from that operand and add the address of it to my list to add the address it is loaded at to. Except with jmp and call in which case I do the opposite.

_________________
Post 24 Dec 2009, 22:13
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Code:
format pe dll
alpha = $401000

mov eax, someLabel
mov edx, alpha
someLabel:    


How do you detect which one is just a mere constant and which one is a label? Or do you plan to force programmers to add something extra to address references to be able to detect them?
Post 24 Dec 2009, 23:35
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
I don't. I just avoid using constants that fall within that range.

I guess I could put the whole thing in a virtual block to move it away from the constant, or use a loop with eq to compare the argument against a list of labels and make sure it matches one of them directly, but I haven't bothered yet. Or maybe the in directive. Or putting an ! in front if I want it relocated and using match.

_________________
Post 24 Dec 2009, 23:38
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
To compare with a list of labels is easy if you have the list, you can use match. The list has to begin and end with an extra symbol, like '+' (invalid label name anyway), because otherwise the first and last labels would get skipped (i.e no 'a' or 'b' before/after so match would not "match" Laughing):

Code:
macro testlabel label
{
  match a =label b, list
  \{
    display 'found'
  \}
}

define list + la1 jo2 cc +

testlabel dd
testlabel cc    

_________________
Previously known as The_Grey_Beast
Post 25 Dec 2009, 01:13
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3

< 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 YouTube, Twitter.

Website powered by rwasa.