flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > struc problem?

Author
Thread Post new topic Reply to topic
quiveror



Joined: 20 Jun 2003
Posts: 34
quiveror
consider the prog below:

struc bar x,y {
.x dd x
.y dd y
}
foo bar 1,2
.z=3
dd foo.z

For the last line, I've got "error: undefined symbol." I thought that should be perfectly legal. Why?

Thanks,
Post 08 May 2006, 17:51
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
The problem is that "foo bar 1, 2" defines two labels, foo.x and foo.y. foo.y hides .z so if you use dd foo.y.z will work:
Code:
struc bar x,y {
.x dd x 
.y dd y 
} 

dd foo.y.z ; Works even here (where has more sense to do this)
foo bar 1,2
.z=3 
dd foo.y.z

dd .z ; This works too because there is nothing in the middle hiding .z
    
Post 08 May 2006, 18:09
View user's profile Send private message Reply with quote
quiveror



Joined: 20 Jun 2003
Posts: 34
quiveror
This is so weird. I was thinking of an easy way to put more members to the instance of struc bar. If the situation is just like this, it will be no use. I have to know the last member's name of struc bar in order to use those additional members(.z) and if I use your technique, later on, I cannot modify the last member of struc bar too. Crying or Very sad
Post 08 May 2006, 20:02
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
ooh, maybe you want this then:
http://flatassembler.net/docs.php?article=win32 wrote:
The definition of structure may also be based on some of the already defined structure types and it inherits all the fields from that structure, for example:

struct CPOINT POINT
color dd ?
ends

defines the same structure as:

struct CPOINT
x dd ?
y dd ?
color dd ?
ends


Also you can add some "tag" at the end of the struc to do what you want I thing.

Code:
struc bar x,y {
  .x dd x
  .y dd y
  .strucScope:
}  

dd foo.strucScope.z ; Works even here (where has more sense to do this)
foo bar 1,2 
.z=3  
dd foo.strucScope.z

dd .z ; This works too because there is nothing in the middle hiding .z    
Post 08 May 2006, 20:47
View user's profile Send private message Reply with quote
quiveror



Joined: 20 Jun 2003
Posts: 34
quiveror
the "tag" method is good. thanks
Post 09 May 2006, 07:41
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.