mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-24 12:02:08 +00:00
Ignore RPN strings when their value is known
This commit is contained in:
@@ -861,14 +861,25 @@ void out_PCRelByte(struct Expression *expr)
|
||||
{
|
||||
checkcodesection();
|
||||
checksectionoverflow(1);
|
||||
if (!rpn_isKnown(expr) || pCurrentSection->nOrg == -1) {
|
||||
pCurrentSection->tData[nPC] = 0;
|
||||
createpatch(PATCHTYPE_JR, expr);
|
||||
pCurrentSection->nPC++;
|
||||
nPC++;
|
||||
pPCSymbol->nValue++;
|
||||
} else {
|
||||
/* Target is relative to the byte *after* the operand */
|
||||
uint16_t address = pCurrentSection->nOrg + nPC + 1;
|
||||
/* The offset wraps (jump from ROM to HRAM, for loopexample) */
|
||||
int16_t offset = expr->nVal - address;
|
||||
|
||||
/* Always let the linker calculate the offset. */
|
||||
pCurrentSection->tData[nPC] = 0;
|
||||
createpatch(PATCHTYPE_JR, expr);
|
||||
pCurrentSection->nPC++;
|
||||
nPC++;
|
||||
pPCSymbol->nValue++;
|
||||
|
||||
if (offset < -128 || offset > 127) {
|
||||
yyerror("jr target out of reach (expected -129 < %d < 128)", offset);
|
||||
out_AbsByte(0);
|
||||
} else {
|
||||
out_AbsByte(offset);
|
||||
}
|
||||
}
|
||||
rpn_Free(expr);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user