added DEC and INC direct page indexed x and absolute indexed x
This commit is contained in:
parent
4998c9c4dc
commit
688c2aaaa3
4
TODO
4
TODO
|
@ -23,13 +23,9 @@ Operations Not Yet Implemented:
|
|||
- 0x9a : TXS
|
||||
- 0xba : TSX
|
||||
- 0xcb : WAI
|
||||
- 0xd6 : DEC direct page indexed x
|
||||
- 0xdb : STP
|
||||
- 0xdc : JMP absolute indirect long
|
||||
- 0xde : DEC absolute indexed x
|
||||
- 0xf6 : INC direct page indexed x
|
||||
- 0xfc : JSR absolute indexed x indirect
|
||||
- 0xfe : INC absolute indexed x
|
||||
CPU:
|
||||
- More work on interrupts
|
||||
- Decimal mode support
|
||||
|
|
176
cpu.js
176
cpu.js
|
@ -87,9 +87,13 @@ function CPU_65816() {
|
|||
0x8c : STY_absolute, 0x84 : STY_direct_page,
|
||||
0x94 : STY_direct_page_indexed_x,
|
||||
0x1a : INC_accumulator, 0xe6 : INC_direct_page,
|
||||
0xee : INC_absolute, 0xe8 : INX, 0xc8 : INY,
|
||||
0xee : INC_absolute, 0xf6 : INC_direct_page_indexed_x,
|
||||
0xfe : INC_absolute_indexed_x,
|
||||
0xe8 : INX, 0xc8 : INY,
|
||||
0x3a : DEC_accumulator, 0xce : DEC_absolute,
|
||||
0xde : DEC_absolute_indexed_x,
|
||||
0xc6 : DEC_direct_page, 0xca : DEX, 0x88 : DEY,
|
||||
0xd6 : DEC_direct_page_indexed_x,
|
||||
0x9c : STZ_absolute, 0x64 : STZ_direct_page,
|
||||
0x9e : STZ_absolute_indexed_x,
|
||||
0x74 : STZ_direct_page_indexed_x, 0x9b : TXY,
|
||||
|
@ -4748,7 +4752,7 @@ var DEC_absolute = {
|
|||
return 3;
|
||||
},
|
||||
execute: function(cpu, bytes) {
|
||||
var location = (bytes[1]<<8)|bytes[0]
|
||||
var location = (bytes[1]<<8)|bytes[0];
|
||||
var temp;
|
||||
if(cpu.p.e|cpu.p.m) {
|
||||
temp = cpu.mmu.read_byte(location);
|
||||
|
@ -4791,6 +4795,54 @@ var DEC_absolute = {
|
|||
}
|
||||
};
|
||||
|
||||
var DEC_absolute_indexed_x = {
|
||||
bytes_required: function() {
|
||||
return 3;
|
||||
},
|
||||
execute: function(cpu, bytes) {
|
||||
var location = ((bytes[1]<<8)|bytes[0]) + cpu.r.x;
|
||||
var temp;
|
||||
if(cpu.p.e|cpu.p.m) {
|
||||
temp = cpu.mmu.read_byte(location&0xffff);
|
||||
if(temp===0) {
|
||||
cpu.mmu.store_byte(location&0xffff, 0xff);
|
||||
cpu.p.n = 1;
|
||||
cpu.p.z = 0;
|
||||
} else {
|
||||
temp--;
|
||||
cpu.mmu.store_byte(location&0xffff, temp);
|
||||
cpu.p.n = temp >> 7;
|
||||
if(temp===0) {
|
||||
cpu.p.z = 1;
|
||||
} else {
|
||||
cpu.p.z = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var low_byte = cpu.mmu.read_byte(location&0xffff);
|
||||
var high_byte = cpu.mmu.read_byte((location+1)&0xffff);
|
||||
temp = (high_byte<<8) | low_byte;
|
||||
if(temp===0) {
|
||||
temp = 0xffff;
|
||||
cpu.p.n = 1;
|
||||
cpu.p.z = 0;
|
||||
} else {
|
||||
temp--;
|
||||
cpu.p.n = temp >> 15;
|
||||
if(temp===0) {
|
||||
cpu.p.z = 1;
|
||||
} else {
|
||||
cpu.p.z = 0;
|
||||
}
|
||||
}
|
||||
high_byte = temp >> 8;
|
||||
low_byte = temp & 0x00ff;
|
||||
cpu.mmu.store_byte(location&0xffff, low_byte);
|
||||
cpu.mmu.store_byte((location+1)&0xffff, high_byte);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var DEC_direct_page = {
|
||||
bytes_required: function() {
|
||||
return 2;
|
||||
|
@ -4839,6 +4891,54 @@ var DEC_direct_page = {
|
|||
}
|
||||
};
|
||||
|
||||
var DEC_direct_page_indexed_x = {
|
||||
bytes_required: function() {
|
||||
return 2;
|
||||
},
|
||||
execute: function(cpu, bytes) {
|
||||
var location = bytes[0] + cpu.r.d + cpu.r.x;
|
||||
var temp;
|
||||
if(cpu.p.e|cpu.p.m) {
|
||||
temp = cpu.mmu.read_byte(location&0xffff);
|
||||
if(temp===0) {
|
||||
cpu.mmu.store_byte(location&0xffff, 0xff);
|
||||
cpu.p.n = 1;
|
||||
cpu.p.z = 0;
|
||||
} else {
|
||||
temp--;
|
||||
cpu.mmu.store_byte(location&0xffff, temp);
|
||||
cpu.p.n = temp >> 7;
|
||||
if(temp===0) {
|
||||
cpu.p.z = 1;
|
||||
} else {
|
||||
cpu.p.z = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var low_byte = cpu.mmu.read_byte(location&0xffff);
|
||||
var high_byte = cpu.mmu.read_byte((location+1)&0xffff);
|
||||
temp = (high_byte<<8) | low_byte;
|
||||
if(temp===0) {
|
||||
temp = 0xffff;
|
||||
cpu.p.n = 1;
|
||||
cpu.p.z = 0;
|
||||
} else {
|
||||
temp--;
|
||||
cpu.p.n = temp >> 15;
|
||||
if(temp===0) {
|
||||
cpu.p.z = 1;
|
||||
} else {
|
||||
cpu.p.z = 0;
|
||||
}
|
||||
}
|
||||
high_byte = temp >> 8;
|
||||
low_byte = temp & 0x00ff;
|
||||
cpu.mmu.store_byte(location&0xffff, low_byte);
|
||||
cpu.mmu.store_byte((location+1)&0xffff, high_byte);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var INX = {
|
||||
bytes_required:function() {
|
||||
return 1;
|
||||
|
@ -4942,6 +5042,42 @@ var INC_absolute = {
|
|||
}
|
||||
};
|
||||
|
||||
var INC_absolute_indexed_x = {
|
||||
bytes_required: function() {
|
||||
return 3;
|
||||
},
|
||||
execute: function(cpu, bytes) {
|
||||
var location = ((bytes[1]<<8)|bytes[0]) + cpu.r.x;
|
||||
var temp;
|
||||
if(cpu.p.e|cpu.p.m) {
|
||||
temp = cpu.mmu.read_byte(location&0xffff) + 1;
|
||||
temp &= 0xff;
|
||||
cpu.p.n = temp >> 7;
|
||||
cpu.mmu.store_byte(location&0xffff, temp);
|
||||
if(temp===0) {
|
||||
cpu.p.z = 1;
|
||||
} else {
|
||||
cpu.p.z = 0;
|
||||
}
|
||||
} else {
|
||||
var low_byte = cpu.mmu.read_byte(location&0xffff);
|
||||
var high_byte = cpu.mmu.read_byte((location+1)&0xffff);
|
||||
temp = (high_byte<<8) | low_byte;
|
||||
temp++;
|
||||
cpu.p.n = temp >> 15;
|
||||
high_byte = temp >> 8;
|
||||
low_byte = temp & 0x00ff;
|
||||
cpu.mmu.store_byte(location&0xffff, low_byte);
|
||||
cpu.mmu.store_byte((location+1)&0xffff, high_byte);
|
||||
if(((high_byte<<8)|low_byte)===0) {
|
||||
cpu.p.z = 1;
|
||||
} else {
|
||||
cpu.p.z = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var INC_direct_page = {
|
||||
bytes_required: function() {
|
||||
return 2;
|
||||
|
@ -4978,6 +5114,42 @@ var INC_direct_page = {
|
|||
}
|
||||
};
|
||||
|
||||
var INC_direct_page_indexed_x = {
|
||||
bytes_required: function() {
|
||||
return 2;
|
||||
},
|
||||
execute: function(cpu, bytes) {
|
||||
var location = bytes[0] + cpu.r.d + cpu.r.x;
|
||||
var temp;
|
||||
if(cpu.p.e|cpu.p.m) {
|
||||
temp = cpu.mmu.read_byte(location&0xffff) + 1;
|
||||
temp &= 0xff;
|
||||
cpu.mmu.store_byte(location&0xffff, temp);
|
||||
cpu.p.n = temp >> 7;
|
||||
if(temp===0) {
|
||||
cpu.p.z = 1;
|
||||
} else {
|
||||
cpu.p.z = 0;
|
||||
}
|
||||
} else {
|
||||
var low_byte = cpu.mmu.read_byte(location&0xffff);
|
||||
var high_byte = cpu.mmu.read_byte((location+1)&0xffff);
|
||||
temp = (high_byte<<8) | low_byte;
|
||||
temp++;
|
||||
cpu.p.n = temp >> 15;
|
||||
high_byte = temp >> 8;
|
||||
low_byte = temp & 0x00ff;
|
||||
cpu.mmu.store_byte(location&0xffff, low_byte);
|
||||
cpu.mmu.store_byte((location+1)&0xffff, high_byte);
|
||||
if(((high_byte<<8)|low_byte)===0) {
|
||||
cpu.p.z = 1;
|
||||
} else {
|
||||
cpu.p.z = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var STA_direct_page_indexed_x = {
|
||||
bytes_required: function() {
|
||||
return 2;
|
||||
|
|
Loading…
Reference in New Issue