assembler - Add feature: throw useful error on references to undefined constants

This commit is contained in:
n loewen 2023-08-24 16:01:56 +01:00
parent d6b55db381
commit d56eb34a44
1 changed files with 7 additions and 0 deletions

View File

@ -303,6 +303,13 @@ function decodeInstructions(source) {
// Operands - Handle references to constants
if (line.argument.startsWith(ASM_CONSTANT_PREFIX)) {
dbg(1, `References '${line.argument}'`);
if (typeof constants[line.argument.substring(1)] === 'undefined') {
console.error();
console.error(`Error: Undefined constant '${line.argument}'`);
console.error(` at line ${line.number}`);
console.error();
throw new Error('Undefined constant');
}
decodedArg = decodeNumericOp(constants[line.argument.substring(1)]); // substring(1) strips '>'
}