as: Fix matching against symbols - scc - simple c99 compiler (HTM) git clone git://git.simple-cc.org/scc (DIR) Log (DIR) Files (DIR) Refs (DIR) Submodules (DIR) README (DIR) LICENSE --- (DIR) commit fbbb55d7a577fa91580b836acccfb44e23ca3084 (DIR) parent 34ac4d9aeeace5c62f6e08195da7bf9fa7e0b17a (HTM) Author: Roberto E. Vargas Caballero <k0ga@shike2.com> Date: Sat, 10 Feb 2024 23:31:55 +0100 as: Fix matching against symbols All the targets where checking incorrectly against symbol, and they forced to use immediates for symbols forcing to do things like: .EQU $main,$1 instead of the normal .EQU main,$1 Diffstat: M src/cmd/as/parser.c | 12 +++++++++++- M src/cmd/as/target/powerpc/ins.c | 2 +- M src/cmd/as/target/x80/ins.c | 2 +- M src/cmd/as/target/x86/ins.c | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) --- (DIR) diff --git a/src/cmd/as/parser.c b/src/cmd/as/parser.c @@ -273,7 +273,7 @@ regctx(int mode) Node * operand(char **strp) { - int imm = 0; + int c, imm = 0; Node *np; textp = *strp; @@ -291,10 +291,20 @@ operand(char **strp) np->addr = ASTR; next(); break; + case IDEN: + c = ahead(); + if (c != EOS && c != ',') + goto expression; + np = node(IDEN, NULL, NULL); + np->sym = yylval.sym; + np->addr = ANUMBER; + next(); + break; case '$': next(); imm = 1; default: + expression: if (!imm) { np = moperand(); } else { (DIR) diff --git a/src/cmd/as/target/powerpc/ins.c b/src/cmd/as/target/powerpc/ins.c @@ -97,7 +97,7 @@ match(Op *op, Node **args) error("overflow in immediate operand"); break; case ASYM: - if (np->addr != AIMM || np->op != IDEN) + if (np->op != IDEN) return 0; break; case ADIRECT: (DIR) diff --git a/src/cmd/as/target/x80/ins.c b/src/cmd/as/target/x80/ins.c @@ -191,7 +191,7 @@ match(Op *op, Node **args) error("overflow in immediate operand"); break; case ASYM: - if (np->addr != AIMM || np->op != IDEN) + if (np->op != IDEN) return 0; break; case ADIRECT: (DIR) diff --git a/src/cmd/as/target/x86/ins.c b/src/cmd/as/target/x86/ins.c @@ -228,7 +228,7 @@ match(Op *op, Node **args) error("overflow in immediate operand"); break; case ASYM: - if (np->addr != AIMM || np->op != IDEN) + if (np->op != IDEN) return 0; break; case ADIRECT: