mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-22 03:02:06 +00:00
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:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user