added TRB and both addressing modes for it

This commit is contained in:
Preston Skupinski 2011-06-01 13:01:16 -04:00
parent 48c6fe5cf9
commit 4f98a754b7
2 changed files with 67 additions and 3 deletions

2
TODO
View File

@ -8,8 +8,6 @@ Testing:
- Tests needed for interrupt support
- Tests needed for the numerous other operations added
Operations Not Yet Implemented:
- 0x14 : TRB direct page
- 0x1c : TRB absolute
- 0x42 : WDM
- 0x5c : JMP absolute long
- 0x7c : JMP absolute indexed x indirect

68
cpu.js
View File

@ -209,7 +209,8 @@ function CPU_65816() {
0x24 : BIT_direct_page,
0x3c : BIT_absolute_indexed_x,
0x34 : BIT_direct_page_indexed_x,
0x0c : TSB_absolute, 0x04 : TSB_direct_page };
0x0c : TSB_absolute, 0x04 : TSB_direct_page,
0x1c : TRB_absolute, 0x14 : TRB_direct_page };
/**
* Take a raw hex string representing the program and execute it.
@ -425,6 +426,71 @@ var MMU = {
}
};
var TRB_absolute = {
bytes_required:function() {
return 3;
},
execute:function(cpu, bytes) {
var location = (bytes[1]<<8)|bytes[0];
if(cpu.p.e|cpu.p.m) {
var data = cpu.mmu.read_byte(location);
if((data & cpu.r.a) === 0) {
cpu.p.z = 1;
} else {
cpu.p.z = 0;
}
cpu.mmu.store_byte(location, (~cpu.r.a & data));
} else {
var low_byte = cpu.mmu.read_byte(location);
var high_byte = cpu.mmu.read_byte((location+1)&0xffff);
var data = (high_byte<<8) | low_byte;
if((data & cpu.r.a) === 0) {
cpu.p.z = 1;
} else {
cpu.p.z = 0;
}
data &= ~cpu.r.a;
high_byte = data >> 8;
low_byte = data & 0xff;
cpu.mmu.store_byte(location, low_byte);
cpu.mmu.store_byte((location+1)&0xffff, high_byte);
}
}
};
var TRB_direct_page = {
bytes_required:function() {
return 2;
},
execute:function(cpu, bytes) {
var location = bytes[0] + cpu.r.d;
if(cpu.p.e|cpu.p.m) {
var data = cpu.mmu.read_byte(location&0xffff);
if((data & cpu.r.a) === 0) {
cpu.p.z = 1;
} else {
cpu.p.z = 0;
}
cpu.mmu.store_byte(location&0xffff, (~cpu.r.a & data));
} else {
var low_byte = cpu.mmu.read_byte(location&0xffff);
var high_byte = cpu.mmu.read_byte((location+1)&0xffff);
var data = (high_byte<<8) | low_byte;
if((data & cpu.r.a) === 0) {
cpu.p.z = 1;
} else {
cpu.p.z = 0;
}
data &= ~cpu.r.a;
high_byte = data >> 8;
low_byte = data & 0xff;
cpu.mmu.store_byte(location&0xffff, low_byte);
cpu.mmu.store_byte((location+1)&0xffff, high_byte);
}
}
};
var TSB_absolute = {
bytes_required:function() {
return 3;