flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Structure of Structures

Author
Thread Post new topic Reply to topic
Hypnos



Joined: 24 Nov 2005
Posts: 4
Hypnos 24 Nov 2005, 12:20
Hi Everybody...this is my first post..hope it's not too stupid Smile

i'd like to know why it's not possible to declare a struc like this :
i

struct POLYGON
points POINTS 100 dup (<?,?>)
ends

or

struct POLYGON
times 100 POINTS <?,?>
ends

it would be easier for changing the number of points in the polygon..

with a standard

struct POINTS
x dd ?
y dd ?
ends

thx Cya
Post 24 Nov 2005, 12:20
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 24 Nov 2005, 17:56
i personaly prefer: polygon rd 100*sizeof.POINTS :]
Post 24 Nov 2005, 17:56
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 24 Nov 2005, 17:58
you meant

polygon rb 100*sizeof.POINTS

right?
Post 24 Nov 2005, 17:58
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 24 Nov 2005, 18:23
oh, error, i meant
Code:
polygon label dword
rb 100*sizeof.POINTS    


we don't want type-cast always
Wink
Post 24 Nov 2005, 18:23
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Hypnos



Joined: 24 Nov 2005
Posts: 4
Hypnos 24 Nov 2005, 20:44
ok thx...but how do you initialize polygon with the value of 3 points for example? (polygon rb 3*sizeof.POINTS )

I think it's not possible this way...according to the FAQ

Quote:
The other solution can be used when array doesn't have to be initialized and your data structure has the fixed size - like the ones defined with the struct macro (the struct defines the constant holding the size of structure with the name created by attaching sizeof. before the name of structure). Then you can easily calculate how much space the array needs and just reserve this amount of bytes:

StrucArray rb 100*sizeof.MYSTRUCT

Post 24 Nov 2005, 20:44
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 24 Nov 2005, 22:39
no, RB means reserve bytes, eg. with uninitialized value. They aren't really defined, they are reserved. If they are placed at the end of executable, then they won't even appear in file, they will only stay marked somewhere in header.
Post 24 Nov 2005, 22:39
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Hypnos



Joined: 24 Nov 2005
Posts: 4
Hypnos 24 Nov 2005, 22:52
So...how can i do?
How can i initialize all my points?

i don't want to write sth like this :

struct POLYGON
point1 POINTS
point2 POINTS
...
point100 POINTS
ends

poly POLYGON <1,1>, <2,1>,......,<5,8>

Maybe sth like this (like in the FAQ) :

Polygon:
rept 100
{
local s
s POINTS
}

but then...how do i initialize the points, what's the right syntax?
Post 24 Nov 2005, 22:52
View user's profile Send private message Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend 26 Nov 2005, 23:06
Code:
struc POLY count {
 . POINT
 rb (count-1)*sizeof.POINT }

; USAGE:
  polygon_with_10_corners       POLY 10    

EDIT: And the version with initialized points:
Code:
struc POLY [value] {
 common
  ..poly_flag equ false
 forward
  if ..poly_flag eq false
   . POINT value
   ..poly_flag equ true
  else
   local ..label
   ..label POINT value
  end if
}
; USAGE:
  polygon_with_10_corners       POLY <1,1>, <2,2>, <3,3>, <4,4>, <5,5>, <6,6>, <7,7>, <8,8>, <9,9>, <10,10>    
Post 26 Nov 2005, 23:06
View user's profile Send private message Visit poster's website Reply with quote
Hypnos



Joined: 24 Nov 2005
Posts: 4
Hypnos 27 Nov 2005, 10:46
ohhh thanks a lot!!! It finally works Smile that's great...

Cya
Post 27 Nov 2005, 10:46
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.