flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > struct/union (small bug ?)

Author
Thread Post new topic Reply to topic
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji
Code:
include 'win32a.inc'

struct X
v1 dd ?
  union
  v3 dd ?
  v5 dd ?
  v2 dd ?
  ends
ends

jmp toto.v2.x    ;does compile Smile

jmp toto.v5.x    ;does not compile Sad

toto    X
.x :

;both should compile ! ... because "union" <<<----- !!

    

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 09 Nov 2010, 12:49
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
toto.v2, toto.v3 and toto.v5 are not local labels. So the last one (toto.v2) will be the current global label that .x attaches to.
Post 09 Nov 2010, 13:16
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji
Quote:
toto.v2, toto.v3 and toto.v5 are not local labels.

(i know that)
sorry, i'm not agree with you.
their symbolic values are merged with "union"
at the symbolic level, toto.v2 = toto.v3 = toto.v5

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 09 Nov 2010, 13:42
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
union can't perform magic. How would you make three current global labels and have .x attach to them all?
Post 09 Nov 2010, 13:45
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

three current global labels ...

here is the problem !
toto.v2, toto.v3 and toto.v5 are not 3 global labels
but only one, with three different names, because "union"

mov [toto.v3],1
mov eax,[toto.v2]
;eax == 1


_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 09 Nov 2010, 14:02
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
ouadji wrote:
toto.v2, toto.v3 and toto.v5 are not 3 global labels
Yeah, they are actually.

But even if they weren't, it is not possible for union make all three attach to .x simultaneously.
Post 09 Nov 2010, 14:08
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

obviously that is possible
fasm is built in assembler and with assembler all is possible.
In this case, the symbolic value of "union" is not respected.
I think that should be fixed,
Tomasz ? what do you think about that ?

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 09 Nov 2010, 14:18
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
Are you aware that union is a macro? Hence the assembler has no knowledge that union even exists.
Post 09 Nov 2010, 14:27
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

one point Wink

edit:
maybe create a new feature in the macro language to allow this ?

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 09 Nov 2010, 14:33
View user's profile Send private message Send e-mail Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael
The question is: what are you exactly trying to achieve and why?
Post 09 Nov 2010, 16:11
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

no, it's not a question about "what" and "how",
just a matter of theory ...
a matter about compiler overall coherence.

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 09 Nov 2010, 17:12
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
As "struct" is just a macro, the only real view of "compiler coherence" would be when looking at what is processed after the macro is expanded. And when you look at preprocessed source, everything works exactly as it should.

Macros may be changed and improved over time (you can even have various "struct" alternatives provided, so that you can simply include the one of your choice, but still have some other available) and it has nothing to do with compiler itself. As it seems that using parser-stage locals mechanism with "struct" macros bothers you much, I modified the "struct" (which before had undefined behavior with respect to what global label context it leaves for the code that follows) to define context of its own name. So now:
Code:
toto X 
.x:    
is going to define "toto.x" label.
Post 09 Nov 2010, 23:36
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.