added TCD and TDC

This commit is contained in:
Preston Skupinski 2011-05-13 12:18:16 -04:00
parent 20012291fc
commit 8500c21618

49
cpu.js
View File

@ -22,7 +22,7 @@ function CPU_65816() {
x:0, // X Index Register
y:0, // Y Index Register
d:0, // Direct Page Register
s:0xff, // Stack Pointer
s:0xff, // Stack Pointer
pc:0, // Program Counter
dbr:0, // Data Bank Register
k:0 // Program Bank Register
@ -76,7 +76,7 @@ function CPU_65816() {
0x9e : STZ_absolute_indexed_x,
0x74 : STZ_direct_page_indexed_x, 0x9b : TXY,
0xbb : TYX, 0xaa : TAX, 0xa8 : TAY, 0x8a : TXA,
0x98 : TYA, 0x4c : JMP_absolute,
0x98 : TYA, 0x5b : TCD, 0x7b : TDC, 0x4c : JMP_absolute,
0x6c : JMP_absolute_indirect, 0x80 : BRA, 0x82 : BRL,
0xf0 : BEQ, 0xd0 : BNE, 0x90 : BCC, 0xb0 : BCS,
0x50 : BVC, 0x70 : BVS, 0x10 : BPL, 0x30 : BMI,
@ -2285,6 +2285,51 @@ var TYX = {
}
};
var TCD = {
bytes_required:function() {
return 1;
},
execute:function(cpu) {
// Transfers 16-bits regardless of setting.
if(cpu.p.e|cpu.p.m) {
cpu.r.d = (cpu.r.b<<8)|cpu.r.a;
} else {
cpu.r.d = cpu.r.a;
}
cpu.p.n = cpu.r.d >> 15;
if(cpu.r.d===0) {
cpu.p.z = 1;
} else {
cpu.p.z = 0;
}
}
};
var TDC = {
bytes_required:function() {
return 1;
},
execute:function(cpu) {
// Transfers 16-bits regardless of setting.
if(cpu.p.e|cpu.p.m) {
cpu.r.a = cpu.r.d & 0xff;
cpu.r.b = cpu.r.d >> 8;
cpu.p.n = cpu.r.b >> 7;
} else {
cpu.r.a = cpu.r.d;
cpu.p.n = cpu.r.a >> 7;
}
if(cpu.r.a===0) {
cpu.p.z = 1;
} else {
cpu.p.z = 0;
}
}
};
var STZ_absolute = {
bytes_required: function() {
return 3;