News:

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

Arrays and structs

Started by RedXVII, December 06, 2005, 09:22:15 PM

Previous topic - Next topic

RedXVII

Thanks alot AeroASM and everyone else :U I should be able to get this working now  :cheekygreen:

Pro3carp3: whats the code for the way you would do it?

RedXVII

Just tried it:

console.asm(10) : error A2179: structure improperly initialized
console.asm(10) : error A2065: expected : )

.data
charArray CHAR_INFO 400 dup(0)     //line 10  !?!?!


you sure that works AeroASM? what does the error mean?

pro3carp3

This is untested and probably needs corrections, but it is the general idea:



...
struct CharInfo
   union
      dword UnicodeChar
      byte Char
   ends
   word Attributes
CharInfo ends

...

.data?

...

CharArray CharInfo 400 dup (<?>)

...

.code

...

;In program initialization:
   xor eax, eax
   mov edi, offset CharArray
   mov ecx, SIZEOF(CharInfo)*400
   cld
   rep stosd

LGC

RedXVII

That wont compile either - is the format wrong?

console.asm(14) : error A2138: invalid data initializer
console.asm(14) : error A2036: too many initial values for structure

.data?
charArray CHAR_INFO 400 dup (<?>)                    //Line 14   

MichaelW

This should compile OK:

charArray CHAR_INFO 400 dup (<>)

eschew obfuscation

RedXVII

WOOHOO! It compiles and worked as i wanted it

Thanks alot everyone - ive now learnt how to use these so now my programming is going to get more interesting.

Thanks alot everyone!!!  :U   :U