Add link-time RST instruction

This allows using a label as the argument to a `rst` instruction
Fixes rednex#448
This commit is contained in:
ISSOtm
2020-01-14 00:02:22 +01:00
parent 359a048b6e
commit b1cd730db2
14 changed files with 98 additions and 4 deletions

View File

@@ -2065,9 +2065,10 @@ z80_rrca : T_Z80_RRCA
z80_rst : T_Z80_RST const_8bit
{
if (rpn_isReloc(&$2))
yyerror("Address for RST must be absolute");
else if (($2.nVal & 0x38) != $2.nVal)
if (rpn_isReloc(&$2)) {
rpn_CheckRST(&$2, &$2);
out_RelByte(&$2);
} else if (($2.nVal & 0x38) != $2.nVal)
yyerror("Invalid address $%x for RST", $2.nVal);
else
out_AbsByte(0xC7 | $2.nVal);

View File

@@ -242,6 +242,13 @@ void rpn_CheckHRAM(struct Expression *expr, const struct Expression *src)
expr->nRPNPatchSize++;
}
void rpn_CheckRST(struct Expression *expr, const struct Expression *src)
{
*expr = *src;
pushbyte(expr, RPN_RST);
expr->nRPNPatchSize++;
}
void rpn_LOGNOT(struct Expression *expr, const struct Expression *src)
{
*expr = *src;