From 57b734a7dfc3767cedc1940ed55cce3262a955ef Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Mon, 11 Jan 2021 01:37:36 +0100 Subject: [PATCH] Reinstate RL into the _RS family Removal of colon-less labels lifted the grammar ambiguity that prevented `RL` from being usable as a variable declarator. Thus, reinstate its functionality. --- src/asm/parser.y | 4 ++-- src/asm/rgbasm.5 | 1 - test/asm/rs.asm | 43 +++++++++++++++++++++++++++++++++++++++++++ test/asm/rs.err | 0 test/asm/rs.out | 16 ++++++++++++++++ 5 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 test/asm/rs.asm create mode 100644 test/asm/rs.err create mode 100644 test/asm/rs.out diff --git a/src/asm/parser.y b/src/asm/parser.y index 36cb8504..795b8d06 100644 --- a/src/asm/parser.y +++ b/src/asm/parser.y @@ -450,7 +450,7 @@ static inline void failAssertMsg(enum AssertionType type, char const *msg) %token T_POP_SECTION T_POP_FRAGMENT %token T_POP_RB %token T_POP_RW -%token T_POP_RL +// There is no T_POP_RL, only T_Z80_RL %token T_POP_MACRO %token T_POP_ENDM %token T_POP_RSRESET T_POP_RSSET @@ -864,7 +864,7 @@ rs_uconst : /* empty */ { | uconst ; -rl : T_LABEL T_POP_RL rs_uconst { +rl : T_LABEL T_Z80_RL rs_uconst { sym_AddEqu($1, sym_GetConstantValue("_RS")); sym_AddSet("_RS", sym_GetConstantValue("_RS") + 4 * $3); } diff --git a/src/asm/rgbasm.5 b/src/asm/rgbasm.5 index dcdd6db1..a67cd131 100644 --- a/src/asm/rgbasm.5 +++ b/src/asm/rgbasm.5 @@ -971,7 +971,6 @@ There are five commands in the RS group of commands: .It Ic RB Ar constexpr Ta Sets the preceding symbol to Ic _RS No and adds Ar constexpr No to Ic _RS . .It Ic RW Ar constexpr Ta Sets the preceding symbol to Ic _RS No and adds Ar constexpr No * 2 to Ic _RS . .It Ic RL Ar constexpr Ta Sets the preceding symbol to Ic _RS No and adds Ar constexpr No * 4 to Ic _RS . -(In practice, this one cannot be used due to a bug). .El .Pp If the argument to diff --git a/test/asm/rs.asm b/test/asm/rs.asm new file mode 100644 index 00000000..694f3f33 --- /dev/null +++ b/test/asm/rs.asm @@ -0,0 +1,43 @@ + +a1 rb 1 +a2 rw 1 +a3 rl 1 + +PRINTLN "a1 = ", a1 +PRINTLN "a2 = ", a2 +PRINTLN "a3 = ", a3 +PRINTLN "_RS = ", _RS + + +b1 rb 1 +b2 rw 1 +b3 rl 1 + +PRINTLN "b1 = ", b1 +PRINTLN "b2 = ", b2 +PRINTLN "b3 = ", b3 +PRINTLN "_RS = ", _RS + + +rsset 42 +c1 rb 1 +c2 rw 1 +c3 rl 1 + +PRINTLN "c1 = ", c1 +PRINTLN "c2 = ", c2 +PRINTLN "c3 = ", c3 +PRINTLN "_RS = ", _RS + + +rsreset +d1 rb 1 +d2 rw 1 +d3 rl 1 + +PRINTLN "d1 = ", d1 +PRINTLN "d2 = ", d2 +PRINTLN "d3 = ", d3 +PRINTLN "_RS = ", _RS + + diff --git a/test/asm/rs.err b/test/asm/rs.err new file mode 100644 index 00000000..e69de29b diff --git a/test/asm/rs.out b/test/asm/rs.out new file mode 100644 index 00000000..db465b28 --- /dev/null +++ b/test/asm/rs.out @@ -0,0 +1,16 @@ +a1 = $0 +a2 = $1 +a3 = $3 +_RS = $7 +b1 = $7 +b2 = $8 +b3 = $A +_RS = $E +c1 = $2A +c2 = $2B +c3 = $2D +_RS = $31 +d1 = $0 +d2 = $1 +d3 = $3 +_RS = $7