News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

structure arrays in NASM

Started by thomasantony, April 22, 2005, 07:13:45 AM

Previous topic - Next topic

thomasantony

How do I declare an array of structs in NASM? You know in MASM you would do:

label    STRUCTNAME  10 dup (<?>)


Thomas :U
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free

Tedd

Short answer: you don't :P

The simplest thing to do is define SIZE_STRUCT and then do resb 10*SIZE_STRUCT
No snowflake in an avalanche feels responsible.

rea

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