hi,

just paste what i asked in mirc #win32asm. nobody could answer it there:

<NOPerator> i'm trying to define a variable with a lots of data in the .data section
<NOPerator> so that the whole data goes over 5 lines
<NOPerator> (because there is a limit of line length in asm, isn't it?)
<NOPerator> but now i want to repeat that 5 lines for about 50 times. usually i would do it with "variable type 50 dup(data)
<NOPerator> but it doesn't work for that 5 lines, because of the last bracket, i suppose
<NOPerator> the last bracket of that dup(data)<---
<NOPerator> it is in the fifth line
<NOPerator> does anybody have an idea?

here is the example:



pra realPOINT <60.0,60.0>,<120.0,60.0>,<180.0,60.0>,<240.0,60.0>,<300.0,60.0>,<360.0,60.0>,<420.0,60.0>
realPOINT <60.0,120.0>,<120.0,120.0>,<180.0,120.0>,<240.0,120.0>,<300.0,120.0>,<360.0,120.0>,<420.0,120.0>
realPOINT <60.0,180.0>,<120.0,180.0>,<180.0,180.0>,<240.0,180.0>,<300.0,180.0>,<360.0,180.0>,<420.0,180.0>
realPOINT <60.0,240.0>,<120.0,240.0>,<180.0,240.0>,<240.0,240.0>,<300.0,240.0>,<360.0,240.0>,<420.0,240.0>


and this is what i tried:



pra realPOINT 5 dup(<60.0,60.0>,<120.0,60.0>,<180.0,60.0>,<240.0,60.0>,<300.0,60.0>,<360.0,60.0>,<420.0,60.0>
realPOINT <60.0,120.0>,<120.0,120.0>,<180.0,120.0>,<240.0,120.0>,<300.0,120.0>,<360.0,120.0>,<420.0,120.0>
realPOINT <60.0,180.0>,<120.0,180.0>,<180.0,180.0>,<240.0,180.0>,<300.0,180.0>,<360.0,180.0>,<420.0,180.0>
realPOINT <60.0,240.0>,<120.0,240.0>,<180.0,240.0>,<240.0,240.0>,<300.0,240.0>,<360.0,240.0>,<420.0,240.0>)


but this doesn't work.
Posted on 2001-12-01 15:06:27 by NOP-erator
If its so repetative, why not just write a pre-compiler while loop:



pra LABEL realPOINT ; Name the data...
Count = 1
WHILE Count LE 50 ; Place 50 copies
realPOINT <60.0,60.0>,<120.0,60.0>,<180.0,60.0>,<240.0,60.0>,<300.0,60.0>,<360.0,60.0>,<420.0,60.0>
Count = Count + 1
ENDM


Then you can define as much as you want...

Hope it helps..
:alright:
NaN
Posted on 2001-12-01 23:19:04 by NaN


pra realPOINT 5 dup(<60.0,60.0>,<120.0,60.0>,<180.0,60.0>,<240.0,60.0>,<300.0,60.0>,<360.0,60.0>,<420.0,60.0>,\
<60.0,120.0>,<120.0,120.0>,<180.0,120.0>,<240.0,120.0>,<300.0,120.0>,<360.0,120.0>,<420.0,120.0>,\
<60.0,180.0>,<120.0,180.0>,<180.0,180.0>,<240.0,180.0>,<300.0,180.0>,<360.0,180.0>,<420.0,180.0>,\
<60.0,240.0>,<120.0,240.0>,<180.0,240.0>,<240.0,240.0>,<300.0,240.0>,<360.0,240.0>,<420.0,240.0>)
Posted on 2001-12-01 23:58:02 by huh
hi,

@huh: your solution really surprised me. the reason is: when i add this "\" at the end of each line, the whole 5 lines are seen as just one. but there were rumours of line length limit in asm. and i'm pretty sure that this line would be too long, woulnd't it? anyways, it worked! thanks

@NaN: this is very l33t! i like your solution very much. but i don't know anything about macros, and this seems to be a macro (ENDM) .......or have you done just a mistake? shouldn't it be (ENDW)? anyways, what exactly is this? what does pre-compile mean? haha, the best would be if you would try to explain the whole thing you did, ok? i would appreciate that very much. thanks!

ok,
bye
Posted on 2001-12-02 03:10:51 by NOP-erator
Sure... here goes:

pra LABEL realPOINT ; Name the data...

THis is needed because the while loop will place alot of data. Since its in a loop, you cant add the "label" indication as well, or you would get 50 labels..

Count = 1

This is a pre-compiler variable (since its not declaired as any type, just a value). This is a data variable MASM sets up for when it compiles ASM to binary. It doesnt actaully get placed in the exe however, its just a 'script value' to tell the compiler how you want things to compile.

WHILE Count LE 50 ; Place 50 copies

Begin the "scripted while loop". Again, this is only telling the compiler how to do things, this itself is not turned into code.

realPOINT <60.0,60.0>,<120.0,60.0>,<180.0,60.0>,<240.0,60.0>,<300.0,60.0>,<360.0,60.0>,<420.0,60.0>

This is the ONLY code placed in the final exe. It will be placed 50 times over (while the scripted while is still looping thu).

Count = Count + 1

Increment the script variable... for the loop..

ENDM

This must be ENDM. Its just masm's way. Its logical to think it should be ENDW, but its not. MASM likes to share this with FOR and MACRO's as well. All i can realy say about this.


To finialize, This IS NOT a macro. Its simply a WHILE loop acting like a FOR x=1:50... It uses pre-compiler scripting to instruct the compiler how to place data in the final exe. If you wanted to make it fancy, you could alway then place this in a MACRO and give it "features", but you just wanted the job done, to this it the direct answer :)

Hope this helps... glad you like it..
:alright:
NaN
Posted on 2001-12-02 11:37:26 by NaN