flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > struct (does not compile ?)

Author
Thread Post new topic Reply to topic
ouadji



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

"A" does compile, "B" does not compile

why ?

Code:
A) ;does compile
include 'win32a.inc'

struct BB
 union
  v1 dd ?
  v2 dd ?
 ends
ends

struct AA
v3 dd ?
v4 BB
ends
    
Code:
B) ;does NOT compile <------ ??
include 'win32a.inc'

struct BB
 union
  v1 dd ?
  v2 dd ?
 ends
ends


struct AA
v3 dd ?
BB    ;<----- B) = A) - "v4" .... here "BB" is alone.
ends       ;there are no other differences between A and B
    


that said, both below compile

C) D) == A) B) - union

Code:
C) ;does compile
include 'win32a.inc'

struct BB
  v1 dd ?
  v2 dd ?
ends

struct AA
v3 dd ?
v4 BB
ends
    
Code:
D) ;does compile
include 'win32a.inc'

struct BB
  v1 dd ?
  v2 dd ?
ends

struct AA
v3 dd ?
BB  ;<--- B) is alone, but here it does compile
ends
    

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


Joined: 16 Jun 2003
Posts: 7409
Location: Kraków, Poland
Tomasz Grysztar
Yes, this macro was unfinished in this aspect and I forgot about it. Here's the corrected "define@struct" macro:
Code:
macro define@struct name,[field,type,def]
 { common
    local list
    list equ
   forward
    if ~ field eq .
     name#field type def
     sizeof.#name#field = $ - name#field
    else
     label name#.#type
     rb sizeof.#type
    end if
    local value
    match any, list \{ list equ list, \}
    list equ list <value>
   common
    sizeof.#name = $
    restruc name
    match values, list \{
    struc name value \\{
    match any, fields@struct \\\{ fields@struct equ fields@struct,.,name,<values> \\\}
    match , fields@struct \\\{ label .
   forward
     match , value \\\\{ field type def \\\\}
     match any, value \\\\{ field type value
                            if ~ field eq .
                             rb sizeof.#name#field - ($-field)
                            end if \\\\}
   common \\\} \\}
    macro name value \\{
    match any, fields@struct \\\{ \\\local anonymous
                                  fields@struct equ fields@struct,anonymous,name,<values> \\\}
    match , fields@struct \\\{ label .
   forward
     match , value \\\\{ type def \\\\}
     match any, value \\\\{ \\\\local ..field
                           ..field = $
                           type value
                           if ~ field eq .
                            rb sizeof.#name#field - ($-..field)
                           end if \\\\}
   common \\\} \\} \} }    
There may be some more fixing need to make the standalone "BB" work also outside the "struct", though.
Post 09 Nov 2010, 23:09
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7409
Location: Kraków, Poland
Tomasz Grysztar
OK, I'm uploading the package with finished (I hope) corrections.
Post 09 Nov 2010, 23:28
View user's profile Send private message Visit poster's website Reply with quote
ouadji



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

flat assembler 1.69.25 for Windows
size: 891 kilobytes
last update: 09 Nov 2010

now, with this last update,
this below does not compile ???

(with the previous version of "struct", it compiled without problem.)
Code:
include 'win32a.inc'

struct BB
  v1 dd ?
  v2 dd ?
ends

mov eax,dword[toto.v2.x]

toto BB

.x :
    

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 10 Nov 2010, 01: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: 16842
Location: In your JS exploiting you and your system
revolution
Code:
mov eax,dword[toto.x]    
Post 10 Nov 2010, 01:07
View user's profile Send private message Visit poster's website Reply with quote
ouadji



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

no, with the prévious version of "struct"
mov eax,dword[toto.v2.x] compiled without problem

I develop a full highlighting of struct macro ! (for next Wink)
I absolutely need a reference.


_________________
I am not young enough to know everything (Oscar Wilde)- Image


Last edited by ouadji on 10 Nov 2010, 01:25; edited 2 times in total
Post 10 Nov 2010, 01:11
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: 16842
Location: In your JS exploiting you and your system
revolution
ouadji wrote:

no, with the prévious version of "struct"

mov eax,dword[toto.v2.x] compiled without problem

But this is a new version. It has different behaviour.
Post 10 Nov 2010, 01:20
View user's profile Send private message Visit poster's website Reply with quote
ouadji



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

Tomasz, why this is no longer allowed?
This new version greatly limits the possibilities of "struct".
Is this really your wish? Confused

Code:
include 'win32a.inc'

struct BB
  v1 dd ?
  v2 dd ?
ends

mov eax,dword[toto.v2.x]

toto BB

.x :
    

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



Joined: 19 Mar 2008
Posts: 1651
baldr
Tomasz Grysztar,

Probably label should explicitly declare whether it wants to have following local labels to be attached to it. Something like
Code:
hello.:  …
goodbye: …
.world:  jmp     hello.world    
Post 10 Nov 2010, 23:57
View user's profile Send private message Reply with quote
ouadji



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

it is true that your idea is interesting baldr, but I do not see the interest on a practical level. I do not think it would bring much more possibilities. That said, once again, it's a original idea.

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


Joined: 16 Jun 2003
Posts: 7409
Location: Kraków, Poland
Tomasz Grysztar
baldr wrote:
Probably label should explicitly declare whether it wants to have following local labels to be attached to it.
If I was to break the long-lived NASM compatibility on this one, I would probably just remove this feature completely.
Post 11 Nov 2010, 07:45
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2796
Location: dank orb
bitRAKE
Tomasz, what method do you use to avoid name collision under SSSO principal? Please, don't remove dot labels - not all labels need some_descriptive_long_text.
Post 11 Nov 2010, 08:21
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7409
Location: Kraków, Poland
Tomasz Grysztar
Did I say I was going to remove them? Wink
Post 11 Nov 2010, 09:35
View user's profile Send private message Visit poster's website Reply with quote
ouadji



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

200% agree with baldr.
dot label are very useful.
Without them, fasm lose much of its interest.

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


Joined: 16 Jun 2003
Posts: 7409
Location: Kraków, Poland
Tomasz Grysztar
If it was not for NASM compatibility I would go for something more fitting the overall fasm's design, like nested local namespaces closed with "end" directive. But being compatible with NASM at least in this aspect doesn't usually hurt - though you have to be careful with macro design to take it into consideration. But this is all academic discussion - this feature is to well-established in fasm's 1.x architecture to change it now.
Post 11 Nov 2010, 10:18
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:

this feature is to well-established in fasm's 1.x architecture
to change it now.
very good conclusion Tomasz !
don't touch anything, it's perfect like that
fasm does not have to be like this or like that ...
fasm can be simply himself. Razz

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 11 Nov 2010, 11:23
View user's profile Send private message Send e-mail 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.