From 4228e3e8900af0d42e5e2384af90deeef8882008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ni=C3=B1o=20D=C3=ADaz?= Date: Wed, 26 Apr 2017 22:02:47 +0100 Subject: [PATCH] Document dependency problem for EQUS and MACRO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/asm/rgbasm.5 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/asm/rgbasm.5 b/src/asm/rgbasm.5 index 6dd69876..6fed01eb 100644 --- a/src/asm/rgbasm.5 +++ b/src/asm/rgbasm.5 @@ -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