How to initialize big arrays: error A2042:statement too complex

Started by becoolnike, May 01, 2011, 01:27:02 PM

Previous topic - Next topic

becoolnike

I am trying to initialize this array 10 by 10, but the masm compilers trows an error. Syntax too complex!

My background is c/c++. I find very weird the limitations of MASM.

this is how i am trying to initialize the array:

pic1 byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
          1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
          1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
          1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
          1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
          1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
          1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
          1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
          1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
          1, 1, 1, 1, 1, 1, 1, 1, 1, 1

MichaelW

You're running up against a line-length limitation. Either of these should work:

      pic1 byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
           byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
           byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
           byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
           byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
           byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
           byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
           byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
           byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
           byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1

      pic2 byte 10*10 dup(1)

eschew obfuscation


jj2007

Caution with the sizeof operator: pic1=10, pic2=100 bytes. This is because only the line behind the label is being considered when calculating sizeof pic1.

dedndave

you can solve that by rolling your own...
pic1       byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
           byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
           byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
           byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
           byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
           byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
           byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
           byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
           byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
           byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
SIZEOFpic1 EQU $-pic1