flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Bug (?) with Virtual

Author
Thread Post new topic Reply to topic
KronosRJ



Joined: 03 Jul 2005
Posts: 15
KronosRJ 27 Oct 2005, 05:13
Hi,

I don't even know if this is a bug, but I am having trouble with the code below:

Code:
        mov eax , .teste
        virtual at 0
                Aloha:
                        dd ?
        end virtual
.teste:
    


Is this a bug? Is there any way (besides preposing a dot before Aloha) to bypass this feature/bug?
Post 27 Oct 2005, 05:13
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 27 Oct 2005, 05:45
what are you expecting and what are you getting?
Post 27 Oct 2005, 05:45
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 27 Oct 2005, 05:46
If you are talking about refering to .teste instead of Aloha.teste, then you might want to try the "local" keyword. However, I am not sure if it works outside of a macro
Post 27 Oct 2005, 05:46
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 27 Oct 2005, 08:21
comrade: it doesn't, there's no "local" for virtual.
but you shouldn't declare virtual inside some code namespace, place it somwhere where it doesn't matter.
Post 27 Oct 2005, 08:21
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20537
Location: In your JS exploiting you and your system
revolution 27 Oct 2005, 09:09
Try this:
Code:
       mov eax , .teste 
        virtual at 0 
                ..Aloha: 
                        dd ? 
        end virtual 
.teste:
mov ebx,[..Aloha]
     
Post 27 Oct 2005, 09:09
View user's profile Send private message Visit poster's website Reply with quote
Ancient One



Joined: 28 Feb 2005
Posts: 55
Ancient One 27 Oct 2005, 13:22
that's not a bug.. label define inside virtual has the same rules outside it.. rev's solution should work.
Post 27 Oct 2005, 13:22
View user's profile Send private message MSN Messenger Reply with quote
KronosRJ



Joined: 03 Jul 2005
Posts: 15
KronosRJ 27 Oct 2005, 15:39
I was thinking of something like:

xpto: ;//This would be my function

mov eax , .ret

;//In here, I would use some macros for parameters and local variables, using virtual
virtual at 0
Aloha:
.data1 dd ?
end virtual

.ret:
ret[/quote][/code]
Post 27 Oct 2005, 15:39
View user's profile Send private message Reply with quote
KronosRJ



Joined: 03 Jul 2005
Posts: 15
KronosRJ 27 Oct 2005, 15:40
What does the '..' do to the label definition inside the virtual declaration?
Post 27 Oct 2005, 15:40
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 27 Oct 2005, 21:28
".." means that label won't overwrite current namespace:
Code:
a:
..b:
.c: ;this is a.c, not ..b.c
    

i still don't know what you want. are you sure you understand "virtual" right?
Post 27 Oct 2005, 21:28
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
KronosRJ



Joined: 03 Jul 2005
Posts: 15
KronosRJ 30 Oct 2005, 02:31
Yes, but, since virtual stablishes a new section, it's labels should not 'break' the proc's labels...
I am inside a proc, named MyProc ... I created a macro that uses virtual to create local labels (Yes, I know that it has already been done, but I wanted to create use only code I could be sure to understand), and they use a pure label and the dot notation internally...
I imagined that, since the label inside the virtual isn't really there (it is outside the proc's address), it should not cut the proc's label mechanism...
Have I been clear enough?
Post 30 Oct 2005, 02:31
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8367
Location: Kraków, Poland
Tomasz Grysztar 30 Oct 2005, 09:28
The "." mechanism (like "@@", too) is processed by the parser, before the assembly stage - the "virtual" and other such directives have no meaning yet at that time. The parser just attaches name beginning with dot to the last "global label" - that is the one not starting with dot - it met to be defined. At the assembly stage it may become modified in many different ways, but the parsing is already done. For example:
Code:
if 0
 Alpha:
end if
 .a:
virtual
 .b:
end virtual    

after parsing becomes something like:
Code:
if 0
 Alpha:
end if
 Alpha.a:
virtual
 Alpha.b:
end virtual    

and even though when the assembler processes it "Alpha" itself never actually gets defined, the parsing has already been done this way.

This mechanism of "locals" was taken from NASM for its simplicity; for "true" locals you might look for some macro solutions (like the "proc" macro package for Win32, or something like http://board.flatassembler.net/topic.php?t=3744)
Post 30 Oct 2005, 09:28
View user's profile Send private message Visit poster's website Reply with quote
KronosRJ



Joined: 03 Jul 2005
Posts: 15
KronosRJ 03 Nov 2005, 01:05
Thanks everybody.
Post 03 Nov 2005, 01:05
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.