ref: 112098514d412c79e14c45c89b806ebdc68abdd0
parent: 31aa1ea474ec91c7a86ddbe8817d9335fb10ec1b
author: ISSOtm <[email protected]>
date: Tue Feb 11 13:59:55 EST 2020
Fix 1 s/r and 1 r/r conflict Implements the fix suggested [here](https://github.com/rednex/rgbds/issues/44#issuecomment-69360499), which performed better than expected! I'm not \*too\* fond of this but this seems like the right way
--- a/src/asm/asmy.y
+++ b/src/asm/asmy.y
@@ -498,10 +498,12 @@
}
%type <sVal> relocconst
+%type <sVal> relocconst_no_str
%type <nConstValue> const
%type <nConstValue> uconst
%type <nConstValue> const_3bit
%type <sVal> const_8bit
+%type <sVal> const_8bit_no_str
%type <sVal> const_16bit
%type <nConstValue> sectiontype
@@ -1146,7 +1148,7 @@
out_Skip(1);
nListCountEmpty++;
}
- | const_8bit
+ | const_8bit_no_str
{
out_RelByte(&$1);
}
@@ -1198,6 +1200,14 @@
}
;
+const_8bit_no_str : relocconst_no_str
+ {
+ if( (rpn_isKnown(&$1)) && (($1.nVal < -128) || ($1.nVal > 255)) )
+ warning(WARNING_TRUNCATION, "Expression must be 8-bit");
+ $$ = $1;
+ }
+;
+
const_16bit : relocconst
{
if ((rpn_isKnown(&$1)) && (($1.nVal < -32768) || ($1.nVal > 65535)))
@@ -1207,14 +1217,7 @@
;
-relocconst : T_ID
- {
- rpn_Symbol(&$$, $1);
- }
- | T_NUMBER
- {
- rpn_Number(&$$, $1);
- }
+relocconst : relocconst_no_str
| string
{
char *s = $1;
@@ -1223,6 +1226,16 @@
free(s);
rpn_Number(&$$, r);
+ }
+;
+
+relocconst_no_str : T_ID
+ {
+ rpn_Symbol(&$$, $1);
+ }
+ | T_NUMBER
+ {
+ rpn_Number(&$$, $1);
}
| T_OP_LOGICNOT relocconst %prec NEG { rpn_LOGNOT(&$$, &$2); }
| relocconst T_OP_LOGICOR relocconst { rpn_BinaryOp(RPN_LOGOR, &$$, &$1, &$3); }