Hi all!

I quite new to MASM and I have run into troubles ....

I?m begining to code macro?s but my problem is that I cannot get the macro?s to work when I insert JMP?s, LOOP?s and unconditionel jump's into them !?!?!?

Example:


myfun MACRO

move eax, 0
jmp test
test:
test eax, eax
jnz test2
jmp over
test2:
mov ebx, 1
over:

ENDM


Anyway, just a dumb example ... When I insert this macro in my code more than once I get 'redefinition error' or something like that ....

I think you wizz's get the point !!! I wanna insert a block of code many times in source without having to rename the functions all over again ...

I really hope you guys can help me !!! All help is appreciated !!

Catch 22
Posted on 2003-06-15 04:34:42 by catch 22
Macro just paste the code u made to your progs.

So when you wont to do sth like this u can use


;When u dont have nested macro or loops with @@: label then:

myfun MACRO

move eax, 0
jmp @F
@@:
test eax, eax
jnz @F:
jmp over
@@:
mov ebx, 1
over:

ENDM


@@: <---- label

@F <---- jmp forwrd to nearrest @@:
@B <---- jmp backward to nearrest @@:


;second method


myfun MACRO test1,test2

move eax, 0
jmp test1
test1:
test eax, eax
jnz test2
jmp over
test2:
mov ebx, 1
over:

ENDM



;in code

myfun labelsomeuniquename1,labelsomeuniquename2
Posted on 2003-06-15 04:42:26 by AceEmbler
Oh .... I see !!!

The only problem would then be, if I had say 20 JMP's in my macro that would jump both back and forth. Then I would need to do this right :

myfun MACRO a1,a2,a3,a4 etc etc a20
...
... bla bla jump back and forth
...
ENDM

or could it be done easier ???
Posted on 2003-06-15 04:48:12 by catch 22
You have to mark all your labels as local like this:


myfun MACRO

local test1, test2, over

mov eax, 0
jmp test1
test1:
test eax, eax
jnz test2
jmp over
test2:
mov ebx, 1
over:

ENDM

It let you use your macro as many times as you like.
Posted on 2003-06-15 06:20:46 by Four-F