The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: redskull on May 18, 2006, 04:17:43 AM

Title: Structure Definition length?
Post by: redskull on May 18, 2006, 04:17:43 AM
  When you're initializing data (in my case, arrays of structures), what is the maximum length you can use?  I have a bunch of constant data, which I was hoping to have spaced onto different lines for readability sakes, but anytime it creeps past about 10 physical lines, the assembler spits back a 'statement too complex' and 'line too long' errors.  I searched high and low for multi-line spanning definitions, but didn't find any size-restrictions on it...Am I messing up the declaration, or do I have to break it apart into several different arrays?

Here's the first couple lines, in case i'm declaring it wrong:

MyData POINT        {0,0},{50,100},{100,160},{200,175},{250,150},{320,50},\
                    {0,50},{50,150},{150,175},{200,150},{250,135},{320,125},\
                    {0,125},{55,125},{70,140},{60,150},{55,140},{20,135},{15,165},\
                    etc, etc, etc goes on like this for awhile
Title: Re: Structure Definition length?
Post by: hutch-- on May 18, 2006, 04:51:26 AM
Red,

Give this a blast and see if it works OK with a structure as a data type.


MyData POINT {0,0},{50,100},{100,160},{200,175},{250,150},{320,50}
       POINT {0,50},{50,150},{150,175},{200,150},{250,135},{320,125}
       POINT {0,125},{55,125},{70,140},{60,150},{55,140},{20,135},{15,165}
       etc .....
Title: Re: Structure Definition length?
Post by: redskull on May 18, 2006, 03:32:17 PM
that did it, thanks a bunch :U
Title: Re: Structure Definition length?
Post by: redskull on May 19, 2006, 03:13:24 AM
After some wicked bad debugging nightmares, i've come to realization that SIZEOF and LENGTHOF don't work when you declare things the new way?   :'(
Title: Re: Structure Definition length?
Post by: hutch-- on May 19, 2006, 03:24:30 AM
You can cheat though, put a dummy data item after it and subtract your start address from the start address of the dummy item and you have the length of the first array of data items in BYTES. Divide it by 8 and you have the number of POINT structures.
Title: Re: Structure Definition length?
Post by: KSS on June 24, 2006, 08:45:50 PM
Mr. Hutch,
I use other way, and it not need dummy item.
WndToolbarTbB\
TBBUTTON<STD_FILEOPEN ,IDMC_FileOpen ,TBSTATE_ENABLED,BTNS_BUTTON ,?,0,TXT_WndToolbar_FileOpen>
TBBUTTON<STD_FILESAVE ,IDMC_FileSave ,0 ,BTNS_BUTTON ,?,0,TXT_WndToolbar_FileSave>
TBBUTTON<NULL ,NULL ,TBSTATE_ENABLED,BTNS_SEP ,?,0,0>
TBBUTTON<STD_DELETE ,IDMC_ItemDelete,0 ,BTNS_BUTTON ,?,0,TXT_WndToolbar_ItemDelete>
TBBUTTON<STD_PROPERTIES ,IDMC_ItemEdit ,0 ,BTNS_BUTTON ,?,0,TXT_WndToolbar_ItemEdit>
TBBUTTON<NULL ,NULL ,TBSTATE_ENABLED,BTNS_SEP ,?,0,0>
TBBUTTON<STD_FIND ,IDMC_ItemFind ,0 ,BTNS_BUTTON ,?,0,TXT_WndToolbar_ItemFind>
WndToolbarTbB_Count=($-OFFSET WndToolbarTbB)/Sizeof(TBBUTTON);This string MUST follow directly after WndToolbarTbB
Title: Re: Structure Definition length?
Post by: Ratch on June 24, 2006, 11:56:25 PM
redskull,
     If you want the length of a structure element or a group of structure elements, try the technique shown below.  No dum-dum names or other artifices--just labels.  It is more concise than trying to make LENGTHOF work for complicated constructions.  Also the length of a structure will be assembled by just inserting its name as shown below.  Ratch





PW STRUCT
PW$1     =     $
hBrush  DWORD ?
hdc     DWORD ?
rect    RECT  {}
PW$2     =     $
return  DWORD ?
PW$3     =     $
hwnd    DWORD ?
iColor  DWORD ?
iFigure DWORD ?
PW$4     =     $
PW ENDS

PaintWindow:
SUB ESP,PW$2-PW$1        ;byte length of local area needed
INVOKE GetDC,[ESP.PW.hwnd]
MOV [ESP.PW.hdc],EAX
;.....
;.....
;     
MOV EAX,PW               ;notice how PW will give the length of the structure in bytes
ADD ESP,PW$2-PW$1        ;byte length of local area to release
RET PW$4-PW$3            ;length of parameters PUSH'ed onto stack