flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > "virtual at (REG + VAR)" -- possible?

Author
Thread Post new topic Reply to topic
Frank



Joined: 17 Jun 2003
Posts: 100
Frank
Hi,

"virtual ... end virtual" blocks can be defined at an absolute address ("virtual at 0"), at a register address ("virtual at ebp"), at a register address with a constant offset ("virtual at ebp + 8"), and at a register address with a constant offset that will be computed only later ("virtual at ebp - dynamic_size").

Is it also possible to define a virtual block at a register address plus a variable offset? What I try to do is "virtual at esp + ..stdp", where macros change the value of "..stdp" after every push, pop, invoke, etc.

Thank you,

Frank
Post 26 Jan 2004, 17:10
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7415
Location: Kraków, Poland
Tomasz Grysztar
Adress for a "virtual" directive is a regular address expression (of the same type as the one you use inside the square brackets) and is calculated at the time when the "virtual" directive is processed.
Code:
x = 4

virtual at ebx+x
  test1 dd ?
end virtual

x = 8

virtual at ebx+ecx*4+x
  test2 dd ?
end virtual

        mov     eax,[test1]             ; it's mov eax,[ebx+4]
        mov     eax,[test2]             ; it's mov eax,[ebx+ecx*4+8]   
    

Numerical constants can be redefined (also in "if" clauses), but they cannot be forward-referenced in such case.
Post 26 Jan 2004, 17:30
View user's profile Send private message Visit poster's website Reply with quote
Frank



Joined: 17 Jun 2003
Posts: 100
Frank
Privalov wrote:
and is calculated at the time when the "virtual" directive is processed.


Thank you for explanation and examples. Too bad, that was the "missing link" for a high-convenience, low-risk, fully automatic, framepointerless macro system.
Post 26 Jan 2004, 18:11
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7415
Location: Kraków, Poland
Tomasz Grysztar
But you can achieve something near to what you're looking for by using symbolic constants, like:
Code:
virtual at esp
 x dd ?
 x equ x+offs
end virtual

offs = 0

        mov     eax,[x]         ; mov eax,[esp]

offs = 8

        mov     eax,[x]         ; mov eax,[esp+8]    
Post 26 Jan 2004, 18:19
View user's profile Send private message Visit poster's website Reply with quote
aaro



Joined: 21 Jun 2003
Posts: 107
Location: hel.fi
aaro
Post 26 Jan 2004, 20:40
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
Why not make section of FASM site for such macro tricks? Kind of like 'assembly gems' but for FASM macros Smile

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 26 Jan 2004, 21:14
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7415
Location: Kraków, Poland
Tomasz Grysztar
This forum is a section of FASM site. Wink
And it was made mainly for such 'gems' - most threads here contain some.
Post 26 Jan 2004, 21:19
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-2019, Tomasz Grysztar.

Powered by rwasa.