Deprecate LDH with $00-$FF (#1575)

This commit is contained in:
Sylvie
2024-12-10 21:27:37 -05:00
committed by GitHub
parent f44de0c7ae
commit c1c5b10082
6 changed files with 50 additions and 5 deletions

View File

@@ -1949,13 +1949,23 @@ z80_ldd:
z80_ldh:
Z80_LDH MODE_A COMMA op_mem_ind {
$4.makeCheckHRAM();
if ($4.makeCheckHRAM()) {
warning(
WARNING_OBSOLETE,
"LDH is deprecated with values from $00 to $FF; use $FF00 to $FFFF\n"
);
}
sect_ConstByte(0xF0);
sect_RelByte($4, 1);
}
| Z80_LDH op_mem_ind COMMA MODE_A {
$2.makeCheckHRAM();
if ($2.makeCheckHRAM()) {
warning(
WARNING_OBSOLETE,
"LDH is deprecated with values from $00 to $FF; use $FF00 to $FFFF\n"
);
}
sect_ConstByte(0xE0);
sect_RelByte($2, 1);

View File

@@ -568,16 +568,20 @@ void Expression::makeBinaryOp(RPNCommand op, Expression &&src1, Expression const
}
}
void Expression::makeCheckHRAM() {
bool Expression::makeCheckHRAM() {
isSymbol = false;
if (!isKnown()) {
*reserveSpace(1) = RPN_HRAM;
} else if (int32_t val = value(); val >= 0xFF00 && val <= 0xFFFF) {
// That range is valid, but only keep the lower byte
data = val & 0xFF;
} else if (val < 0 || val > 0xFF) {
} else if (val >= 0 && val <= 0xFF) {
// That range is valid, but deprecated
return true;
} else {
error("Source address $%" PRIx32 " not between $FF00 to $FFFF\n", val);
}
return false;
}
void Expression::makeCheckRST() {

View File

@@ -356,6 +356,12 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
isError = true;
}
value = 0;
} else if (value >= 0 && value <= 0xFF) {
warning(
patch.src,
patch.lineNo,
"LDH is deprecated with values from $00 to $FF; use $FF00 to $FFFF"
);
}
value &= 0xFF;
break;