shithub: rgbds

Download patch

ref: e2de106d7132914ef387bfcf891551c251e03619
parent: adea89f3eb5c274ced47ad138fe0973003a3ee5b
author: yenatch <yenatch@gmail.com>
date: Fri Jul 6 18:48:49 EDT 2018

Use charmaps in const expressions.

--- a/src/asm/asmy.y
+++ b/src/asm/asmy.y
@@ -1243,7 +1243,13 @@
 		| T_NUMBER				{ $$ = $1; }
 		| T_OP_HIGH '(' const ')'		{ $$ = ($3 >> 8) & 0xFF; }
 		| T_OP_LOW '(' const ')'		{ $$ = $3 & 0xFF; }
-		| string				{ $$ = str2int($1); }
+		| string
+		{
+			char *s = $1;
+			int32_t length = charmap_Convert(&s);
+			$$ = str2int2(s, length);
+			free(s);
+		}
 		| T_OP_LOGICNOT const %prec NEG		{ $$ = !$2; }
 		| const T_OP_LOGICOR const		{ $$ = $1 || $3; }
 		| const T_OP_LOGICAND const		{ $$ = $1 && $3; }
--- /dev/null
+++ b/test/asm/equ-charmap.asm
@@ -1,0 +1,4 @@
+SECTION "sec", ROM0
+	charmap "A", 1
+_A_ EQU "A"
+	db _A_
--- /dev/null
+++ b/test/asm/equ-charmap.out.bin
@@ -1,0 +1,1 @@
+
\ No newline at end of file