For stuff like this - intentionally wanting to substitute legal instruction by your own macro:
Код:
macro exx
; exx ; infinite cycle
@exx ; Z80 exx, avoiding infinite cycle of macro calling
endm
you can use the "@" operator to prevent macro matching, ie. `@exx` inside macro definition to do real Z80 `exx`, and in your code you can then:
Код:
exx ; does the macro
@exx ; does the Z80 exx even if "exx" macro exists
The error messages and state recovery in case of infinite loops in DEFINE/MACRO definitions is really bad, sometimes it will raise max-nesting limit, sometimes it will just crash the assembler - I know about it, but I have currently no mood to work on this stuff
Код:
macro test
test
endm
org $8000
test
^^ this needs just few changes to be legit code, for example:
Код:
macro test
nesting = nesting - 1
IF 0 < nesting
test
ENDIF
endm
org $8000
nesting = 4
test
^^^ this is valid source, and will compile fine, but I don't see how you would consider it "different" from yours infinite example (except hitting some guardian-value to notice it's in cycle too much).
So it's not so easy to guard against it... there are some protections in sjasmplus which should catch infinite substitutions and loops, but they are not working that good at this moment, sorry. There's a room for improvement in this area, I agree.