Document dependency problem for EQUS and MACRO

This is hard to detect in MACROs, as there are legitimate uses for
MACROs that call themselves recursively.

For an EQUS, the problem is that its value may be modified at different
points in the source code, so the only way to detect a possible problem
is by doing an analysis at each usage of the EQUS.

Also, since an EQUS may expand to the name of a MACRO and a MACRO can
use an EQUS, it becomes even harder to check all possible problems that
come out of it. It's better to let this task to the programmer.

Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
Antonio Niño Díaz
2017-04-26 22:02:47 +01:00
parent 023b574fc5
commit 4228e3e890

View File

@@ -340,6 +340,14 @@ String-symbols can also be used to define small one-line macros:
Note that a colon (:) following the label-name is not allowed. Note that a colon (:) following the label-name is not allowed.
String equates can't be exported or imported. String equates can't be exported or imported.
.Pp .Pp
.Sy Important note :
An EQUS can be expanded to a string that contains another EQUS
and it will be expanded as well.
This means that, if you aren't careful, you may trap the assembler into an
infinite loop if there's a circular dependency in the expansions.
Also, a MACRO can have inside an EQUS which references the same MACRO, which has
the same problem.
.Pp
.It Sy MACRO .It Sy MACRO
.Pp .Pp
One of the best features of an assembler is the ability to write macros for it. One of the best features of an assembler is the ability to write macros for it.
@@ -401,6 +409,14 @@ LoopyMacro: MACRO
ENDM ENDM
.Ed .Ed
.Pp .Pp
.Sy Important note :
Since a MACRO can call itself (or a different MACRO that calls the first one)
there can be problems of circular dependency.
They trap the assembler in an infinite loop, so you have to be careful when
using recursion with MACROs.
Also, a MACRO can have inside an EQUS which references the same MACRO, which has
the same problem.
.Pp
.Sy Macro Arguments .Sy Macro Arguments
.Pp .Pp
I'd like LoopyMacro a lot better if I didn't have to pre-load the registers I'd like LoopyMacro a lot better if I didn't have to pre-load the registers