flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Help initializing array of struct |
Author |
|
revolution 21 May 2010, 12:01
Add this somewhere before "ArrayStructure":
Code: macro StructureName x,y,life,color,direc { dw x dw y dw life dw color dw direc } |
|||
21 May 2010, 12:01 |
|
alorent 21 May 2010, 12:19
Thanks revolution! It works as you mention.
But, is there any "cleaner" way to do it? I mean, with your solution, if I modify the structure I have to make sure that I also update the macro to avoid inconsistences, which produces a much difficult code to maintain. Thanks! |
|||
21 May 2010, 12:19 |
|
revolution 21 May 2010, 12:22
Try this:
Code: macro StructureName [args] { common local ..x ..x StructureName args } |
|||
21 May 2010, 12:22 |
|
bitshifter 21 May 2010, 13:04
I think by including win32 struct macro we can get all the
functionality we need, correct me if i am wrong... Code: include 'macro\struct.inc' struct StructureName x dw ? y dw ? life dw ? color dw ? direc dw ? ends ArrayStructure: StructureName 0,0,0,1,-4 StructureName 0,0,0,2,-4 StructureName 0,0,0,3,-4 StructureName 0,0,0,4,-4 StructureName 0,0,0,5,-4 StructureName 0,0,0,6,-4 StructureName 0,0,0,7,-4 StructureName 0,0,0,8,-4 StructureName 0,0,0,9,-4 StructureName 0,0,0,1,-4 ... ; TESTING IT... mov ebx,ArrayStructure mov ax,[StructureName.x+ebx] ; first instance.x add ebx,sizeof.StructureName mov dx,[StructureName.y+ebx] ; second instance.y |
|||
21 May 2010, 13:04 |
|
baldr 21 May 2010, 15:50
bitshifter,
You're right. Even more, struct macro defines its argument as both macro and struc so you can use ArrayStructure StructureName too. |
|||
21 May 2010, 15:50 |
|
bitshifter 21 May 2010, 19:41
And you dont even need to initialize the values
Code: ArrayStructure: repeat 256 StructureName end repeat |
|||
21 May 2010, 19:41 |
|
alorent 24 May 2010, 10:19
Thanks a lot bitshifter! Exactly what I was looking for
|
|||
24 May 2010, 10:19 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.