|
|
|
|
|
|
|
|
procFailed = StoreSingleOp(0xC8); break; |
|
|
procFailed = StoreSingleOp(0xC8); break; |
|
|
// --- JMP |
|
|
// --- JMP |
|
|
case 'jmp': |
|
|
case 'jmp': |
|
|
|
|
|
if (tokens.length === 2){ |
|
|
|
|
|
if (tokens[1].startsWith("$") && tokens[1].length === 5){ |
|
|
|
|
|
let v = parseInt(tokens[1].substr(1), 16); |
|
|
|
|
|
if (!isNaN(v)){ |
|
|
|
|
|
op.push(0x4C); |
|
|
|
|
|
op.push(v & 0x000000FF); |
|
|
|
|
|
op.push((v & 0x0000FF00) >> 8); |
|
|
|
|
|
this.__PC += 3; |
|
|
|
|
|
} else { |
|
|
|
|
|
throw new Error("Malformed op-code or value on program address " + toHexString(this.__PC)); |
|
|
|
|
|
} |
|
|
|
|
|
} else if (tokens[1].startsWith("+$") && tokens[1].length === 6){ |
|
|
|
|
|
let v = parseInt(tokens[1].substr(2), 16); |
|
|
|
|
|
if (!isNaN(v)){ |
|
|
|
|
|
op.push(0x6C); |
|
|
|
|
|
op.push(v & 0x000000FF); |
|
|
|
|
|
op.push((v & 0x0000FF00) >> 8); |
|
|
|
|
|
this.__PC += 3; |
|
|
|
|
|
} else { |
|
|
|
|
|
throw new Error("Malformed op-code or value on program address " + toHexString(this.__PC)); |
|
|
|
|
|
} |
|
|
|
|
|
} else { procFailed = true; } |
|
|
|
|
|
} else { procFailed = true; } |
|
|
break; |
|
|
break; |
|
|
// --- JSR |
|
|
// --- JSR |
|
|
case 'jsr': |
|
|
case 'jsr': |
|
|
|
|
|
if (tokens.length === 2){ |
|
|
|
|
|
if (tokens[1].startsWith("$") && tokens[1].length === 5){ |
|
|
|
|
|
let v = parseInt(tokens[1].substr(1), 16); |
|
|
|
|
|
if (!isNaN(v)){ |
|
|
|
|
|
op.push(0x20); |
|
|
|
|
|
op.push(v & 0x000000FF); |
|
|
|
|
|
op.push((v & 0x0000FF00) >> 8); |
|
|
|
|
|
this.__PC += 3; |
|
|
|
|
|
} else { |
|
|
|
|
|
throw new Error("Malformed op-code or value on program address " + toHexString(this.__PC)); |
|
|
|
|
|
} |
|
|
|
|
|
} else { procFailed = true; } |
|
|
|
|
|
} else { |
|
|
|
|
|
procFailed = true; |
|
|
|
|
|
} |
|
|
break; |
|
|
break; |
|
|
// --- LDA |
|
|
// --- LDA |
|
|
case 'lda': |
|
|
case 'lda': |
|
|
|
|
|
procFailed = StoreOp([0xA9, 0xA5, 0xB5, 0xAD, 0xBD, 0xB9, 0xA1, 0xB1], 2, 3); break; |
|
|
break; |
|
|
break; |
|
|
// --- LDX |
|
|
// --- LDX |
|
|
case 'ldx': |
|
|
case 'ldx': |
|
|
|
|
|
procFailed = StoreOp([0xA2, 0xA6, 0xB6, 0xAE, 0xBE, null, null, null], 2, 3); break; |
|
|
break; |
|
|
break; |
|
|
// --- LDY |
|
|
// --- LDY |
|
|
case 'ldy': |
|
|
case 'ldy': |
|
|
|
|
|
procFailed = StoreOp([0xA0, 0xA4, 0xB4, 0xAC, 0xBC, null, null, null], 2, 3); break; |
|
|
break; |
|
|
break; |
|
|
// --- LSR |
|
|
// --- LSR |
|
|
case 'lsr': |
|
|
case 'lsr': |
|
|
break; |
|
|
|
|
|
|
|
|
if (tokens.length === 2){ |
|
|
|
|
|
if (tokens[1].toUpperCase() === 'A'){ |
|
|
|
|
|
op.push(0x4A); |
|
|
|
|
|
this.__PC += 1; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
procFailed = StoreOp([null, 0x46, 0x56, 0x4E, 0x5E, null, null, null], 2, 3); break; |
|
|
// --- NOP |
|
|
// --- NOP |
|
|
case 'nop': |
|
|
case 'nop': |
|
|
procFailed = StoreSingleOp(0xEA); break; |
|
|
procFailed = StoreSingleOp(0xEA); break; |
|
|
// --- ORA |
|
|
// --- ORA |
|
|
case 'ora': |
|
|
case 'ora': |
|
|
break; |
|
|
|
|
|
|
|
|
procFailed = StoreOp([0x09, 0x05, 0x15, 0x0D, 0x1D, 0x19, 0x01, 0x11], 2, 3); break; |
|
|
// --- PHA |
|
|
// --- PHA |
|
|
case 'pha': |
|
|
case 'pha': |
|
|
break; |
|
|
|
|
|
|
|
|
procFailed = StoreSingleOp(0x48); break; |
|
|
// --- PHP |
|
|
// --- PHP |
|
|
case 'php': |
|
|
case 'php': |
|
|
break; |
|
|
|
|
|
|
|
|
procFailed = StoreSingleOp(0x08); break; |
|
|
// --- PLA |
|
|
// --- PLA |
|
|
case 'pla': |
|
|
case 'pla': |
|
|
break; |
|
|
|
|
|
|
|
|
procFailed = StoreSingleOp(0x68); break; |
|
|
// --- PLP |
|
|
// --- PLP |
|
|
case 'plp': |
|
|
case 'plp': |
|
|
break; |
|
|
|
|
|
|
|
|
procFailed = StoreSingleOp(0x28); break; |
|
|
// --- ROL |
|
|
// --- ROL |
|
|
case 'rol': |
|
|
case 'rol': |
|
|
break; |
|
|
|
|
|
|
|
|
if (tokens.length === 2){ |
|
|
|
|
|
if (tokens[1].toUpperCase() === 'A'){ |
|
|
|
|
|
op.push(0x2A); |
|
|
|
|
|
this.__PC += 1; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
procFailed = StoreOp([null, 0x26, 0x36, 0x2E, 0x3E, null, null, null], 2, 3); break; |
|
|
// --- ROR |
|
|
// --- ROR |
|
|
case 'ror': |
|
|
case 'ror': |
|
|
break; |
|
|
|
|
|
|
|
|
if (tokens.length === 2){ |
|
|
|
|
|
if (tokens[1].toUpperCase() === 'A'){ |
|
|
|
|
|
op.push(0x6A); |
|
|
|
|
|
this.__PC += 1; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
procFailed = StoreOp([null, 0x66, 0x76, 0x6E, 0x7E, null, null, null], 2, 3); break; |
|
|
// --- RTI |
|
|
// --- RTI |
|
|
case 'rti': |
|
|
case 'rti': |
|
|
break; |
|
|
|
|
|
|
|
|
procFailed = StoreSingleOp(0x40); break; |
|
|
// --- RTS |
|
|
// --- RTS |
|
|
case 'rts': |
|
|
case 'rts': |
|
|
|
|
|
procFailed = StoreSingleOp(0x60); break; |
|
|
break; |
|
|
break; |
|
|
// --- SBC |
|
|
// --- SBC |
|
|
case 'sbc': |
|
|
case 'sbc': |
|
|
break; |
|
|
|
|
|
|
|
|
procFailed = StoreOp([0xE9, 0xE5, 0xF5, 0xED, 0xFD, 0xF9, 0xE1, 0xF1], 2, 3); break; |
|
|
// --- SEC |
|
|
// --- SEC |
|
|
case 'sec': |
|
|
case 'sec': |
|
|
procFailed = StoreSingleOp(0x38); break; |
|
|
procFailed = StoreSingleOp(0x38); break; |
|
|
|
|
|
|
|
|
break; |
|
|
break; |
|
|
// --- STA |
|
|
// --- STA |
|
|
case 'sta': |
|
|
case 'sta': |
|
|
break; |
|
|
|
|
|
|
|
|
procFailed = StoreOp([null, 0x85, 0x95, 0x8D, 0x9D, 0x99, 0x81, 0x91], 2, 3); break; |
|
|
// --- STX |
|
|
// --- STX |
|
|
case 'stx': |
|
|
case 'stx': |
|
|
break; |
|
|
|
|
|
|
|
|
procFailed = StoreOp([null, 0x86, 0x96, 0x8E, null, null, null, null], 2, 3); break; |
|
|
// --- STY |
|
|
// --- STY |
|
|
case 'sty': |
|
|
case 'sty': |
|
|
break; |
|
|
|
|
|
|
|
|
procFailed = StoreOp([null, 0x84, 0x94, 0x8C, null, null, null, null], 2, 3); break; |
|
|
// --- TAX |
|
|
// --- TAX |
|
|
case 'tax': |
|
|
case 'tax': |
|
|
procFailed = StoreSingleOp(0xAA); break; |
|
|
procFailed = StoreSingleOp(0xAA); break; |
|
|
|
|
|
|
|
|
procFailed = StoreSingleOp(0xA8); break; |
|
|
procFailed = StoreSingleOp(0xA8); break; |
|
|
// --- TSX |
|
|
// --- TSX |
|
|
case 'tsx': |
|
|
case 'tsx': |
|
|
break; |
|
|
|
|
|
|
|
|
procFailed = StoreSingleOp(0xBA); break; |
|
|
// --- TXA |
|
|
// --- TXA |
|
|
case 'txa': |
|
|
case 'txa': |
|
|
procFailed = StoreSingleOp(0x8A); break; |
|
|
procFailed = StoreSingleOp(0x8A); break; |
|
|
// --- TXS |
|
|
// --- TXS |
|
|
case 'txs': |
|
|
case 'txs': |
|
|
break; |
|
|
|
|
|
|
|
|
procFailed = StoreSingleOp(0x9A); break; |
|
|
// --- TYA |
|
|
// --- TYA |
|
|
case 'tya': |
|
|
case 'tya': |
|
|
procFailed = StoreSingleOp(0x98); break; |
|
|
procFailed = StoreSingleOp(0x98); break; |