|
|
@@ -1,62 +0,0 @@ |
|
|
|
const mos6502 = require("./src/chip/MOS6502"); |
|
|
|
const Bank = require("./src/common/bank.js"); |
|
|
|
|
|
|
|
function toHex(v){ |
|
|
|
let r = v.toString(16); |
|
|
|
return (r.length < 2) ? "0" + r : r; |
|
|
|
} |
|
|
|
|
|
|
|
function printBytes(b, acc){ |
|
|
|
var out = ""; |
|
|
|
for (let i=0; i < b.length; i++){ |
|
|
|
if (i % acc === 0 && out !== ""){ |
|
|
|
console.log(out); |
|
|
|
out = "" |
|
|
|
} else { |
|
|
|
out += toHex(b[i]) + " "; |
|
|
|
} |
|
|
|
} |
|
|
|
console.log(out); |
|
|
|
} |
|
|
|
|
|
|
|
var asm = new mos6502.Assembler(); |
|
|
|
var cpu = new mos6502.CPU(); |
|
|
|
cpu.memory = new Bank(65536); |
|
|
|
cpu.memory.clear(); |
|
|
|
var tick = cpu.clk(); |
|
|
|
|
|
|
|
var src = "SEC\n"; |
|
|
|
src += "CLV\n"; |
|
|
|
src += "CLD\n"; |
|
|
|
src += "CLI\n"; |
|
|
|
src += "LDA #$00\n"; |
|
|
|
src += "SBC #$01\n"; |
|
|
|
src += "CLC\n"; |
|
|
|
src += "ADC #$01"; |
|
|
|
|
|
|
|
|
|
|
|
var res = asm.compile(src).result(); |
|
|
|
printBytes(res, 16); |
|
|
|
|
|
|
|
cpu.memory.load(0, res); |
|
|
|
var page = []; |
|
|
|
for (let i = 0; i < 256; i++){ |
|
|
|
cpu.memory.address = i; |
|
|
|
page.push(cpu.memory.byte); |
|
|
|
} |
|
|
|
printBytes(page, 16); |
|
|
|
cpu.reset(); |
|
|
|
|
|
|
|
//console.log(cpu.PC); |
|
|
|
//return; |
|
|
|
tick(); tick(); |
|
|
|
tick(); tick(); |
|
|
|
tick(); tick(); |
|
|
|
tick(); tick(); |
|
|
|
tick(); tick(); |
|
|
|
console.log("A: " + cpu.A); |
|
|
|
tick(); tick(); |
|
|
|
console.log("A: " + cpu.A); |
|
|
|
tick(); tick(); |
|
|
|
tick(); tick(); |
|
|
|
console.log("A: " + cpu.A); |