flat assembler
Message board for the users of flat assembler.

 Index > Macroinstructions > Structure of Structures
Author
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

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
24 Nov 2005, 12:20
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 :]
24 Nov 2005, 17:56
decard

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

polygon rb 100*sizeof.POINTS

right?
24 Nov 2005, 17:58
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
24 Nov 2005, 18:23
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

24 Nov 2005, 20:44
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.
24 Nov 2005, 22:39
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?
24 Nov 2005, 22:52
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>    ```
26 Nov 2005, 23:06
Hypnos

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

Cya
27 Nov 2005, 10:46
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum