mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
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:
@@ -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.
|
||||
String equates can't be exported or imported.
|
||||
.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
|
||||
.Pp
|
||||
One of the best features of an assembler is the ability to write macros for it.
|
||||
@@ -401,6 +409,14 @@ LoopyMacro: MACRO
|
||||
ENDM
|
||||
.Ed
|
||||
.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
|
||||
.Pp
|
||||
I'd like LoopyMacro a lot better if I didn't have to pre-load the registers
|
||||
|
||||
Reference in New Issue
Block a user