i can't believe that this took me an hour because of @catstr. correct use is @CatStr not @catstr. hard to believe that case-sensitive can attack programmers... (and i thought there was something wrong with my version of masm!)



@loop macro
local landmark

ifndef $$RookAttackPawn_d2k
$$RookAttackPawn_d2k = 0
else
$$RookAttackPawn_d2k = $$RookAttackPawn_d2k + 1
endif

landmark textequ @CatStr($_d2kloopcount, %$$RookAttackPawn)
&landmark&:
endm

@endloop macro
jmp @CatStr($_d2kloopcount, %$$RookAttackPawn)
endm



example of usage:


mov eax, 0
@loop
cmp eax, 5
je done

<some other code>

@endloop

done: <--- right now i'm trying to find a way
to fix this problem. so you can have something
like:

@loop
cmp eax, 5
je exit
@endloop


and of course, you can do this without macro:

makeyourselfAlabel:

cmp eax, 5
je done
jmp makeyourselfAlabel
done:


and the problem is that you have to think up of a name for your label everytime you want simple loop like that. beside that, macro is for readability!

and by the way, if you think you can solve the problem i'm having right now, please do!
Posted on 2001-07-21 14:19:38 by disease_2000


-------------------------------------------------------------
@LOOP macro
local landmark

ifndef $$RookAttackPawn
$$RookAttackPawn = 0
else
$$RookAttackPawn = $$RookAttackPawn + 1
endif

landmark textequ @CatStr($_d2kloopcount, %$$RookAttackPawn)
&landmark&:
endm
@ENDLOOP macro
local checkmate
jmp @CatStr($_d2kloopcount, %$$RookAttackPawn)
@@: ; <--- the only solution!!! nothing else works!
endm
-------------------------------------------------------------
usage: (example)

mov eax, 0
@LOOP
cmp eax, 10
je @F

add ebx, eax

@ENDLOOP
-------------------------------------------------------------


the problem with this solution is that you cannot have @@: inside the Loop. this is the only solution i have. everything else that i tried - failed. after i solved this solution, something strange came up... that the macro above can reduce down to:



@LOOP macro
@@:
endm

@ENDLOOP macro
jmp @B
@@:
endm


which works perfectly. but then again... no @@: should be inside the loop. :) how odd that is! anyway, i did learned something from coding this.
Posted on 2001-07-21 16:05:21 by disease_2000