diff --git a/assembler.js b/assembler.js index 44b52b1..ca998d2 100644 --- a/assembler.js +++ b/assembler.js @@ -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 '>' }