The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: thomasantony on April 22, 2005, 07:13:45 AM

Title: structure arrays in NASM
Post by: thomasantony on April 22, 2005, 07:13:45 AM
How do I declare an array of structs in NASM? You know in MASM you would do:

label    STRUCTNAME  10 dup (<?>)


Thomas :U
Title: Re: structure arrays in NASM
Post by: Tedd on April 22, 2005, 09:49:32 AM
Short answer: you don't :P

The simplest thing to do is define SIZE_STRUCT and then do resb 10*SIZE_STRUCT
Title: Re: structure arrays in NASM
Post by: rea on April 22, 2005, 03:30:10 PM
If you use struc macro (because is a macro, nasm dosent have direct support for this things, tought I guess that is a failure :P... most  by the performance than other things :)) ;)

Anyway, when yu define a struc in nasm like...


struc SName
.firstmember resd 2
.secondMember resw 1
endstruc


is not only defined:

SName.firstmember with a value of 0 and
SName.secondMember with a value of 8

I supose I dont need to explain that to you ;).


But in that macro is also defined another thing, apart of the above.. what???

SName_size with the value of 10 :D. That is done automatically when you use the macro endstruc ;).

Then

startOfArrays: resb 10*SName_size
in the case you whan that space in bss section

or

StartOfArray: times 10*SName_size db 0
in the data section filled with zeros