Bläddra i källkod

Jump labels stored. Added some reminder TODOs

master
Bryan Miller 5 år sedan
förälder
incheckning
90a8c38b57
1 ändrade filer med 11 tillägg och 1 borttagningar
  1. +11
    -1
      src/MOS6502.js

+ 11
- 1
src/MOS6502.js Visa fil

if (tokens[0] === 'define'){ if (tokens[0] === 'define'){
// Variable label!! // Variable label!!
} else if (tokens[0][tokens[0].length - 1] === ':'){ } 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){ } else if (tokens[0].length === 3){


let StoreSingleOp = (code)=>{ let StoreSingleOp = (code)=>{
}; };


let StoreBranchOp = (code) => { 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 (tokens.length === 2){
if (token[1][0] === '$' && (tokens[1].length === 3 || tokens[1].length === 5)){ if (token[1][0] === '$' && (tokens[1].length === 3 || tokens[1].length === 5)){
let v = parseInt(token[1].substr(1), 16); let v = parseInt(token[1].substr(1), 16);
procFailed = StoreSingleOp(0xC8); break; procFailed = StoreSingleOp(0xC8); break;
// --- JMP // --- JMP
case 'jmp': case 'jmp':
// TODO: Update value results to test for jump names if value not a number.
if (tokens.length === 2){ if (tokens.length === 2){
if (tokens[1].startsWith("$") && tokens[1].length === 5){ if (tokens[1].startsWith("$") && tokens[1].length === 5){
let v = parseInt(tokens[1].substr(1), 16); let v = parseInt(tokens[1].substr(1), 16);
break; break;
// --- JSR // --- JSR
case 'jsr': case 'jsr':
// TODO: Update value results to test for jump names if value not a number.
if (tokens.length === 2){ if (tokens.length === 2){
if (tokens[1].startsWith("$") && tokens[1].length === 5){ if (tokens[1].startsWith("$") && tokens[1].length === 5){
let v = parseInt(tokens[1].substr(1), 16); let v = parseInt(tokens[1].substr(1), 16);

Laddar…
Avbryt
Spara