The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: becoolnike on May 01, 2011, 01:27:02 PM

Title: How to initialize big arrays: error A2042:statement too complex
Post by: becoolnike on May 01, 2011, 01:27:02 PM
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
Title: Re: How to initialize big arrays: error A2042:statement too complex
Post by: MichaelW on May 01, 2011, 01:40:57 PM
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)

Title: Re: How to initialize big arrays: error A2042:statement too complex
Post by: becoolnike on May 01, 2011, 01:51:26 PM
It works! Thanks a lot Mike!

Title: Re: How to initialize big arrays: error A2042:statement too complex
Post by: jj2007 on May 01, 2011, 03:51:54 PM
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.
Title: Re: How to initialize big arrays: error A2042:statement too complex
Post by: dedndave on May 01, 2011, 03:56:50 PM
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