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)

This commit is contained in:
n loewen 2023-08-21 19:44:16 +01:00
parent 12273a6389
commit a766fd867c
1 changed files with 6 additions and 2 deletions

View File

@ -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)) {