|
|
@@ -319,7 +319,13 @@ function JRS(cpu){ |
|
|
|
} |
|
|
|
|
|
|
|
function LDA(cpu){ |
|
|
|
|
|
|
|
let pmode = [0xA9, 0xA5, 0xB5, null, 0xAD, 0xBD, 0xB9, 0xA1, 0xB1].indexOf(cpu.__op); |
|
|
|
if (ProcessOp(cpu, pmode) === true){ |
|
|
|
cpu.__op = -1; |
|
|
|
cpu.__AR = cpu.__opv; |
|
|
|
cpu.Z = (cpu.__AR === 0); |
|
|
|
cpu.N = (cpu.__AR >= 0x80); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function LDX(cpu){ |
|
|
@@ -519,20 +525,22 @@ function MemAddrFrom(cpu, addr){ |
|
|
|
} |
|
|
|
|
|
|
|
function ALU(cpu, m, b){ |
|
|
|
let v = 0; |
|
|
|
switch(m){ |
|
|
|
case 0: // Addition |
|
|
|
cpu.__AR = (cpu.__AR + b) + ((cpu.C === 1) ? 1 : 0); |
|
|
|
cpu.C = (v >= 256); |
|
|
|
//cpu.C = (this.__AR >= 256); |
|
|
|
break; |
|
|
|
case 1: // Subtraction |
|
|
|
cpu.__AR = (cpu.__AR - b) - ((cpu.C === 0) ? 1 : 0); |
|
|
|
cpu.C = (v >= 0); |
|
|
|
cpu.__AR = (cpu.__AR - b) - ((cpu.C === 0) ? 1 : 0); |
|
|
|
//cpu.C = (this.__AR >= 0); |
|
|
|
cpu.__AR += (cpu.__AR < 0) ? 256 : 0; |
|
|
|
break; |
|
|
|
} |
|
|
|
cpu.__AR &= 0xFF; |
|
|
|
cpu.V = (BITM.isOn(cpu.__AR, 7) === BITM.isOn(b, 7)) && (BITM.val(v, 7) !== BITM.val(cpu.__AR, 7)); |
|
|
|
} |
|
|
|
cpu.V = (BITM.isOn(cpu.__AR, 7) === BITM.isOn(b, 7)) && (BITM.val(cpu.__AR, 7) !== BITM.val(cpu.__AR, 7)); |
|
|
|
cpu.C = (m === 0) ? (this.__AR >= 256) : (cpu.V === 0); |
|
|
|
cpu.N = BITM.val(cpu.__AR, 7); |
|
|
|
|
|
|
|
cpu.__AR &= 0xFF; |
|
|
|
cpu.Z = (cpu.__AR === 0); |
|
|
|
return cpu.__AR; |
|
|
|
} |