|
|
@@ -208,7 +208,14 @@ class Assembler{ |
|
|
|
if (tokens[0] === 'define'){ |
|
|
|
// Variable label!! |
|
|
|
} else if (tokens[0][tokens[0].length - 1] === ':'){ |
|
|
|
// Jump label!! |
|
|
|
// Jump labels! |
|
|
|
// TODO: Finish me!! |
|
|
|
let lbl = tokens[0].substr(0, tokens[0].length - 1); |
|
|
|
if (lbl in this.__jmplabels) |
|
|
|
throw new Error("Jump label '" + lbl + "' defined more than once at program address " + toHexString(this.__PC)); |
|
|
|
if (lbl in this.__varlabels) |
|
|
|
throw new Error("Jump label '" + lbl + "' matches already existing variable name at program address " + toHexString(this.__PC)); |
|
|
|
this.__jmplabels[lbl] = this.__PC; |
|
|
|
} else if (tokens[0].length === 3){ |
|
|
|
|
|
|
|
let StoreSingleOp = (code)=>{ |
|
|
@@ -221,6 +228,7 @@ class Assembler{ |
|
|
|
}; |
|
|
|
|
|
|
|
let StoreBranchOp = (code) => { |
|
|
|
// TODO: If value is not valid, test to see if it's a jump or variable value. |
|
|
|
if (tokens.length === 2){ |
|
|
|
if (token[1][0] === '$' && (tokens[1].length === 3 || tokens[1].length === 5)){ |
|
|
|
let v = parseInt(token[1].substr(1), 16); |
|
|
@@ -436,6 +444,7 @@ class Assembler{ |
|
|
|
procFailed = StoreSingleOp(0xC8); break; |
|
|
|
// --- JMP |
|
|
|
case 'jmp': |
|
|
|
// TODO: Update value results to test for jump names if value not a number. |
|
|
|
if (tokens.length === 2){ |
|
|
|
if (tokens[1].startsWith("$") && tokens[1].length === 5){ |
|
|
|
let v = parseInt(tokens[1].substr(1), 16); |
|
|
@@ -462,6 +471,7 @@ class Assembler{ |
|
|
|
break; |
|
|
|
// --- JSR |
|
|
|
case 'jsr': |
|
|
|
// TODO: Update value results to test for jump names if value not a number. |
|
|
|
if (tokens.length === 2){ |
|
|
|
if (tokens[1].startsWith("$") && tokens[1].length === 5){ |
|
|
|
let v = parseInt(tokens[1].substr(1), 16); |