|
|
@@ -68,8 +68,9 @@ describe("Testing MOS6502 CPU...", function(){ |
|
|
|
asm.reset().compile(prg); |
|
|
|
cpu.memory.clearPage(0); |
|
|
|
cpu.memory.load(0, asm.result()); |
|
|
|
cpu.reset = true; |
|
|
|
tick(); |
|
|
|
cpu.hardReset(); |
|
|
|
//cpu.reset = true; |
|
|
|
//tick(); |
|
|
|
tick(); |
|
|
|
tick(); |
|
|
|
expect(cpu.A).to.equal(0x01); |
|
|
@@ -97,20 +98,35 @@ describe("Testing MOS6502 CPU...", function(){ |
|
|
|
prg += "CLI\n"; |
|
|
|
prg += "LDA #$00\n"; |
|
|
|
prg += "ADC #$01\n"; |
|
|
|
prg += "ADC #$01\n"; |
|
|
|
prg += "ADC #$7F\n"; |
|
|
|
prg += "ADC #$80"; |
|
|
|
asm.reset().compile(prg); |
|
|
|
cpu.memory.clearPage(0); |
|
|
|
cpu.memory.load(0, asm.result()); |
|
|
|
cpu.reset = true; |
|
|
|
tick(); // To reset; |
|
|
|
while (cpu.PC !== 10){ |
|
|
|
cpu.hardReset(); |
|
|
|
//cpu.reset = true; |
|
|
|
//tick(); // To reset; |
|
|
|
while (cpu.PC !== 13){ |
|
|
|
switch(cpu.PC){ |
|
|
|
case 6: |
|
|
|
expect(cpu.A).to.equal(0); break; |
|
|
|
expect(cpu.A).to.equal(0x00); break; |
|
|
|
case 8: |
|
|
|
expect(cpu.A).to.equal(1); break; |
|
|
|
expect(cpu.A).to.equal(0x01); |
|
|
|
expect(cpu.Z).to.equal(0); |
|
|
|
expect(cpu.C).to.equal(0); |
|
|
|
expect(cpu.N).to.equal(0); |
|
|
|
break; |
|
|
|
case 10: |
|
|
|
expect(cpu.A).to.equal(2); break; |
|
|
|
expect(cpu.A).to.equal(0x80); |
|
|
|
expect(cpu.Z).to.equal(0); |
|
|
|
expect(cpu.C).to.equal(0); |
|
|
|
expect(cpu.N).to.equal(1); |
|
|
|
break; |
|
|
|
case 12: |
|
|
|
expect(cpu.A).to.equal(0x00); |
|
|
|
expect(cpu.Z).to.equal(1); |
|
|
|
expect(cpu.C).to.equal(1); |
|
|
|
expect(cpu.N).to.equal(0); |
|
|
|
} |
|
|
|
tick(); |
|
|
|
} |
|
|
@@ -126,7 +142,61 @@ describe("Testing MOS6502 CPU...", function(){ |
|
|
|
}); |
|
|
|
|
|
|
|
describe("ADC Decimal (BCD) Mode...", function(){ |
|
|
|
it("ADC Immediate"); |
|
|
|
it("ADC Immediate", function(){ |
|
|
|
let prg = "CLC\n"; |
|
|
|
prg += "CLV\n"; |
|
|
|
prg += "SED\n"; |
|
|
|
prg += "CLI\n"; |
|
|
|
prg += "LDA #$00\n"; |
|
|
|
prg += "ADC #$01\n"; |
|
|
|
prg += "ADC #$09\n"; |
|
|
|
prg += "ADC #$89\n"; |
|
|
|
prg += "ADC #$01\n"; |
|
|
|
prg += "LDA #$0A\n"; // 0A is an invalid BCD number |
|
|
|
prg += "CLC\n"; // Need to reset the clear flag from previous add. |
|
|
|
prg += "ADC #$01"; |
|
|
|
asm.reset().compile(prg); |
|
|
|
cpu.memory.clearPage(0); |
|
|
|
cpu.memory.load(0, asm.result()); |
|
|
|
cpu.hardReset(); |
|
|
|
//cpu.reset = true; |
|
|
|
//tick(); // To reset; |
|
|
|
while (cpu.PC !== 20){ |
|
|
|
switch(cpu.PC){ |
|
|
|
case 6: |
|
|
|
expect(cpu.A).to.equal(0x00); break; |
|
|
|
case 8: |
|
|
|
expect(cpu.A).to.equal(0x01); |
|
|
|
expect(cpu.Z).to.equal(0); |
|
|
|
expect(cpu.C).to.equal(0); |
|
|
|
expect(cpu.N).to.equal(0); |
|
|
|
break; |
|
|
|
case 10: |
|
|
|
expect(cpu.A).to.equal(0x10); |
|
|
|
expect(cpu.Z).to.equal(0); |
|
|
|
expect(cpu.C).to.equal(0); |
|
|
|
expect(cpu.N).to.equal(0); |
|
|
|
break; |
|
|
|
case 12: |
|
|
|
expect(cpu.A).to.equal(0x99); |
|
|
|
expect(cpu.Z).to.equal(0); |
|
|
|
expect(cpu.C).to.equal(0); |
|
|
|
expect(cpu.N).to.equal(1); |
|
|
|
break; |
|
|
|
case 14: |
|
|
|
expect(cpu.A).to.equal(0x00); |
|
|
|
expect(cpu.Z).to.equal(0); |
|
|
|
expect(cpu.C).to.equal(1); |
|
|
|
expect(cpu.N).to.equal(0); |
|
|
|
break; |
|
|
|
case 19: |
|
|
|
//console.log(cpu.A); |
|
|
|
expect(cpu.A).to.equal(0x11); |
|
|
|
break; |
|
|
|
} |
|
|
|
tick(); |
|
|
|
} |
|
|
|
}); |
|
|
|
it("ADC Zero Page"); |
|
|
|
it("ADC Zero Page, X"); |
|
|
|
it("ADC Absolute"); |
|
|
@@ -150,8 +220,9 @@ describe("Testing MOS6502 CPU...", function(){ |
|
|
|
asm.reset().compile(prg); |
|
|
|
cpu.memory.clearPage(0); |
|
|
|
cpu.memory.load(0, asm.result()); |
|
|
|
cpu.reset = true; |
|
|
|
tick(); // To reset; |
|
|
|
cpu.hardReset(); |
|
|
|
//cpu.reset = true; |
|
|
|
//tick(); // To reset; |
|
|
|
while(cpu.PC !== 11){ |
|
|
|
// NOTE TO SELF: Depending on the OP code, these tests could be |
|
|
|
// checked multiple times, as the cpu may sit at a program cntr |