Update some RGBLINK error messages (#1544)

This commit is contained in:
Sylvie
2024-10-15 19:42:49 -04:00
committed by GitHub
parent e623aeb85d
commit bc5a71ff88
5 changed files with 34 additions and 17 deletions

View File

@@ -359,7 +359,7 @@ static void readSection(
); );
tryReadLong(tmp, file, "%s: Cannot read \"%s\"'s' size: %s", fileName, section.name.c_str()); tryReadLong(tmp, file, "%s: Cannot read \"%s\"'s' size: %s", fileName, section.name.c_str());
if (tmp < 0 || tmp > UINT16_MAX) if (tmp < 0 || tmp > UINT16_MAX)
errx("\"%s\"'s section size (%" PRId32 ") is invalid", section.name.c_str(), tmp); errx("\"%s\"'s section size ($%" PRIx32 ") is invalid", section.name.c_str(), tmp);
section.size = tmp; section.size = tmp;
section.offset = 0; section.offset = 0;
tryGetc( tryGetc(
@@ -379,7 +379,7 @@ static void readSection(
tryReadLong(tmp, file, "%s: Cannot read \"%s\"'s org: %s", fileName, section.name.c_str()); tryReadLong(tmp, file, "%s: Cannot read \"%s\"'s org: %s", fileName, section.name.c_str());
section.isAddressFixed = tmp >= 0; section.isAddressFixed = tmp >= 0;
if (tmp > UINT16_MAX) { if (tmp > UINT16_MAX) {
error(nullptr, 0, "\"%s\"'s org is too large (%" PRId32 ")", section.name.c_str(), tmp); error(nullptr, 0, "\"%s\"'s org is too large ($%" PRIx32 ")", section.name.c_str(), tmp);
tmp = UINT16_MAX; tmp = UINT16_MAX;
} }
section.org = tmp; section.org = tmp;
@@ -405,7 +405,7 @@ static void readSection(
error( error(
nullptr, nullptr,
0, 0,
"\"%s\"'s alignment offset is too large (%" PRId32 ")", "\"%s\"'s alignment offset is too large ($%" PRIx32 ")",
section.name.c_str(), section.name.c_str(),
tmp tmp
); );

View File

@@ -101,9 +101,10 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
case RPN_DIV: case RPN_DIV:
value = popRPN(patch); value = popRPN(patch);
if (value == 0) { if (value == 0) {
if (!isError) if (!isError) {
error(patch.src, patch.lineNo, "Division by 0"); error(patch.src, patch.lineNo, "Division by 0");
isError = true; isError = true;
}
popRPN(patch); popRPN(patch);
value = INT32_MAX; value = INT32_MAX;
} else { } else {
@@ -113,9 +114,10 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
case RPN_MOD: case RPN_MOD:
value = popRPN(patch); value = popRPN(patch);
if (value == 0) { if (value == 0) {
if (!isError) if (!isError) {
error(patch.src, patch.lineNo, "Modulo by 0"); error(patch.src, patch.lineNo, "Modulo by 0");
isError = true; isError = true;
}
popRPN(patch); popRPN(patch);
value = 0; value = 0;
} else { } else {
@@ -128,9 +130,10 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
case RPN_EXP: case RPN_EXP:
value = popRPN(patch); value = popRPN(patch);
if (value < 0) { if (value < 0) {
if (!isError) if (!isError) {
error(patch.src, patch.lineNo, "Exponent by negative"); error(patch.src, patch.lineNo, "Exponent by negative value %" PRId32, value);
isError = true; isError = true;
}
popRPN(patch); popRPN(patch);
value = 0; value = 0;
} else { } else {
@@ -342,10 +345,18 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
case RPN_HRAM: case RPN_HRAM:
value = popRPN(patch); value = popRPN(patch);
if (!isError && (value < 0 || (value > 0xFF && value < 0xFF00) || value > 0xFFFF)) { if (value < 0 || (value > 0xFF && value < 0xFF00) || value > 0xFFFF) {
error(patch.src, patch.lineNo, "Value %" PRId32 " is not in HRAM range", value); if (!isError) {
error(
patch.src,
patch.lineNo,
"Address $%" PRIx32 " for LDH is not in HRAM range",
value
);
isError = true; isError = true;
} }
value = 0;
}
value &= 0xFF; value &= 0xFF;
break; break;
@@ -354,10 +365,12 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
// Acceptable values are 0x00, 0x08, 0x10, ..., 0x38 // Acceptable values are 0x00, 0x08, 0x10, ..., 0x38
// They can be easily checked with a bitmask // They can be easily checked with a bitmask
if (value & ~0x38) { if (value & ~0x38) {
if (!isError) if (!isError) {
error(patch.src, patch.lineNo, "Value %" PRId32 " is not a RST vector", value); error(patch.src, patch.lineNo, "Value $%" PRIx32 " is not a RST vector", value);
isError = true; isError = true;
} }
value = 0;
}
value |= 0xC7; value |= 0xC7;
break; break;

2
test/link/ldh-bad.asm Normal file
View File

@@ -0,0 +1,2 @@
SECTION "bad", ROM0
ldh [$1234+@], a

2
test/link/ldh-bad.out Normal file
View File

@@ -0,0 +1,2 @@
error: ldh-bad.asm(2): Address $1234 for LDH is not in HRAM range
Linking failed with 1 error

View File

@@ -1,2 +1,2 @@
error: rst-bad.asm(2): Value 1 is not a RST vector error: rst-bad.asm(2): Value $1 is not a RST vector
Linking failed with 1 error Linking failed with 1 error