added STA direct page indirect

This commit is contained in:
Preston Skupinski 2011-05-01 17:38:04 -04:00
parent 96a8899204
commit 09fce7cff5
1 changed files with 23 additions and 0 deletions

23
cpu.js
View File

@ -58,6 +58,7 @@ function CPU_65816() {
0xb6 : LDX_direct_page_indexed_y,
0xac : LDY_absolute, 0xa4 : LDY_direct_page, 0xea : NOP,
0x8d : STA_absolute, 0x85 : STA_direct_page,
0x92 : STA_direct_page_indirect,
0x9d : STA_absolute_indexed_x,
0x99 : STA_absolute_indexed_y,
0x95 : STA_direct_page_indexed_x,
@ -308,6 +309,28 @@ var STZ_direct_page_indexed_x = {
}
};
var STA_direct_page_indirect = {
bytes_required:function() {
return 2;
},
execute:function(cpu, bytes) {
var location = bytes[0] + cpu.r.d;
if(cpu.p.m===1) {
var low_byte_loc = cpu.mmu.read_byte(location);
var high_byte_loc = cpu.mmu.read_byte(location+1);
cpu.mmu.store_byte(high_byte_loc | low_byte_loc, cpu.r.a);
} else {
var low_byte_loc = cpu.mmu.read_byte(location);
var high_byte_loc = cpu.mmu.read_byte(location+1);
var absolute_location = high_byte_loc | low_byte_loc;
var low_byte = cpu.r.a & 0x00FF;
var high_byte = cpu.r.a & 0xFF00;
cpu.mmu.store_byte(absolute_location, low_byte);
cpu.mmu.store_byte(absolute_location+1, high_byte);
}
}
};
var LDA_direct_page_indirect = {
bytes_required:function() {
return 2;