The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: RedXVII on April 02, 2007, 07:32:59 PM

Title: Array of Structs
Post by: RedXVII on April 02, 2007, 07:32:59 PM
Arrays of structs kindof work provided you use the SIZE macro in the square brackets. But my question is, has anyone figured out a way of polymorphing or macroing the []'s to do this automatically?


LOCAL x[2]:RECT

mov eax, x[1]               ;This wont work, but its the desired way of doing it :(
mov eax, x[ 1*SIZE x ]   ;This works lovely :)
Title: Re: Array of Structs
Post by: Ratch on April 02, 2007, 08:24:52 PM
RedXVII ,
QuoteBut my question is, has anyone figured out a way of polymorphing or macroing the []'s to do this automatically?

     I believe index brackets in a STRUCT are hardwired to interpret their value in bytes only.  If you know the size of the indexed elements of the array, you could do something like MOV EAX,[1*DWORD] , MOV EAX,[2*WORD], etc.  Ratch