From a766fd867ce7d0b500c78b265566fc2eaf3c2807 Mon Sep 17 00:00:00 2001 From: n loewen Date: Mon, 21 Aug 2023 19:44:16 +0100 Subject: [PATCH] assembler - WIP - Continue refactoring everything, in support of 'set the initial IP to assemble to' feature, etc. (Everything is probably broken... but it's much closer) --- assembler.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/assembler.js b/assembler.js index 63f9cc4..941ba99 100644 --- a/assembler.js +++ b/assembler.js @@ -153,7 +153,7 @@ function handleConstantDefinitions(op, arg, IP, constants) { * @param {SourceLineInfo} line * @returns {Object} **/ -function assembleMnemonicsWithOptionalArgs(line, assemblerState) { +function assembleMnemonicsWithOptionalArgs(line) { if (mnemonicsWithOptionalArgs.indexOf(line.operation) < 0) { console.error(`Missing opcode for line ${line.number}: ${line.source}`); throw new Error("Missing opcode"); @@ -206,7 +206,8 @@ function decodeInstructions(source) { // Decode line by line... for (let i = 0; i < lines.length; i++) { - let line = lines[0]; + let line = lines[i]; + console.log(line); if (line.type === 'code') { const op = line.operation; const arg = null; @@ -246,6 +247,9 @@ function decodeInstructions(source) { /** @typedef {'direct'|'indirect'} AddressingMode **/ let addressingMode = 'direct'; + // Now that it can't be a label or a constant, normalize the opcode + line.operation = line.operation.toLowerCase(); + // Operands - Handle references to labels if (arg !== null && arg.startsWith(ASM_LABEL_PREFIX)) {