flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > last version of "struct"

Author
Thread Post new topic Reply to topic
ouadji



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

This last version of struct works fine, thank you Tomasz.

I just noticed a little thing:


this is not to bore you, certainly not
why this "harassment" about "struct" ... ? Wink
I simply dissects the behavior of "struct" to implement its syntax highlighting (in all cases)

Code:
include 'win32a.inc'

struct EE  ;<--- !
  ea dd ?
ends

struct CC
  ca EE    ;<--- !
  cb dd ?
ends

CC   ;<----- symbol already defined

;this is not very important
;but I am surprised that this does not compile in this case.
    

but,
Code:
include 'win32a.inc'

struct EE
  ea dd ?
ends

struct CC
 union      ;with "union" (or struct), then it does compile
   ca EE
   cb dd ?
 ends
ends

toto CC     ; with a "name", then it does compile
    
thank you Tomasz

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



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
Oh, just remove "label ." from this line:
Code:
    match , fields@struct \\\{ label .    
It was left there by mistake.
Post 11 Nov 2010, 10:55
View user's profile Send private message Visit poster's website Reply with quote
ouadji



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

Could you upload a fixed version.
For this to be accessible to all.

Thank you very much Tomasz.

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



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

oh, this is already done, thank you very much Tomasz

(I have just checked, all is ok)

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



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

this, right below, does compile without problem.
So far so good ! Razz
Code:
include 'win32a.inc'

struct AA
d1 dd ?
d2 dd ?
ends

.x:
jmp AA.d2.x   ;all is ok here, nothing to say.

jmp dodo.y
dodo AA
.y:   
    

but here I noticed a weird little thing:

I'm not sure there is a problem,
I think not, but... in fact, i don't know,Wink
Tomasz? what do you think of this ?
Code:
include 'win32a.inc'

struct .AA
d1 dd ?
d2 dd ?
ends

.x:

jmp .AA.d2.x   ;does not compile  (undefined symbol)

jmp dodo.y     ;but here, it does compile ! 

dodo .AA

.y:   
    

Thank you Tomasz !

(I'm solving struct_names with dot(s) for next Wink)

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



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
".AA.d2" is local label too, so there is no reason why it should be prepended to ".x".

Also: please treat the globals context after the "struct" definition as undefined (as in "not defined in the specification"). There is not much reason to make such macro behave in any specific way in such case, even though possible.
Post 11 Nov 2010, 14:33
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
Oh, one more thing: note than when you define with "struct" a structure with name starting with dot, it will mean nothing to preprocessor, so it still will be a "global" structure; however the structure offsets that it defines will be labels with names starting with dots, so will be treated as locals. Another case of interaction between various layers that better should be avoided.

It could be treated with either "struct" defining the offsets as symbolic constants or disallowing the name of structure to begin with dot. But I doubt that it would really be worth the trouble.
Post 11 Nov 2010, 14:37
View user's profile Send private message Visit poster's website Reply with quote
ouadji



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

ok Tomasz.

.AA == global

but

.AA.d2 == local

I understood ... and above all i understood "why"! wonderfull ! Razz
So, no change here,ok ... I will implement this behavior in Wink.

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



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

i'm sorry Tomasz, but i'm not agree with the behavior and use
of your last macro "struct".

This example is really amazing. Question

Is it impossible (now) to use "struct" symbolically?
Do i have to declare absolutely a "struct name" to use "symbolic offsets" ?

thank you.
Code:
toto: rd 100h

struct BB
g1 dd ?
 struct
  g8 dd ?
  union
  g2 dd ?
  g3 dd ?
  ends
 ends
ends

mov eax ,[toto + BB.g2]  ;undefined symbol BB.g2

    

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



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
This is just a bug, not an expected behavior. I'll look into that later.
Post 12 Nov 2010, 12:57
View user's profile Send private message Visit poster's website Reply with quote
ouadji



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

it is not easy to receive criticisms.
Thank you for your quick reply (as usual) and this good feedback.
ok .. I will wait for the fixed version , I need it to continue to develop Wink.
Once again, thank you Tomasz.

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



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

last update: 12 Nov 2010 14:31:33 UTC

thank you Tomasz for this quick fix.
I checked it, all is ok now.

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



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

I stopped in Wink development with this:
is this normal ? (I don't know !)

Tomasz ?

sorry to bother you with this, thank you in advance

Code:
;does compile
;------------

struct .ZZ
z1 dd ?
ends

struct HH
 h1 dd ?
 .ZZ          ;<--- ".ZZ" (alone)
 h3 dd ?
ends 
    

Code:
;does not compile
;----------------

struct .ZZ
z1 dd ?
ends

struct HH
 h1 dd ?
 h2 .ZZ       ;<--- not ".ZZ alone"  but  "h2 .ZZ"
 h3 dd ?
ends
    

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



Joined: 19 Mar 2008
Posts: 1651
baldr
ouadji,

Read this paragraph again, throughly:
Macroinstruction defined using the struc directive must be preceded by a label (like the data definition directive) when it's used. This label will be also attached at the beginning of every name starting with dot in the contents of macroinstruction.
.ZZ does qualify for every name starting with dot, doesn't it? Then think what will happen during h2 .ZZ expansion inside virtual block at this line:
Code:
match any,fields@struct \{ fields@struct equ fields@struct,.,.ZZ,<values>\}; . is h2, and .ZZ becomes h2.ZZ    
Post 13 Nov 2010, 10:53
View user's profile Send private message Reply with quote
ouadji



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

These special cases are due to the macro language itself.
I understand all this ... but if one don't take into account the macro language (or if one don't knows it) ... the "final result" gives to this struct macro, a appearance, a behavior, that sometimes seems to lack consistency. (only for these special cases)
That said, once again, i understand "why". This is not a big problem at all!
I will implement this behavior in Wink. besides, It's already be done ! Wink

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 13 Nov 2010, 16:47
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.