Allow the bit/res/set bit index to be determined at link time (#1654)

This increments the object file revision number from 11 to 12
since it adds a new `RPN_BIT_INDEX` command.
This commit is contained in:
Rangi
2025-02-12 17:14:10 +01:00
committed by GitHub
parent 48412e9c56
commit 2aef09c8d9
12 changed files with 97 additions and 19 deletions

View File

@@ -363,7 +363,6 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
case RPN_RST:
value = popRPN(patch);
// Acceptable values are 0x00, 0x08, 0x10, ..., 0x38
// They can be easily checked with a bitmask
if (value & ~0x38) {
if (!isError) {
error(patch.src, patch.lineNo, "Value $%" PRIx32 " is not a RST vector", value);
@@ -374,6 +373,21 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
value |= 0xC7;
break;
case RPN_BIT_INDEX: {
value = popRPN(patch);
int32_t mask = getRPNByte(expression, size, patch);
// Acceptable values are 0 to 7
if (value & ~0x07) {
if (!isError) {
error(patch.src, patch.lineNo, "Value $%" PRIx32 " is not a bit index", value);
isError = true;
}
value = 0;
}
value = mask | (value << 3);
break;
}
case RPN_CONST:
value = 0;
for (uint8_t shift = 0; shift < 32; shift += 8) {