mirror of
https://github.com/pskupinski/65816.js.git
synced 2024-06-16 01:29:32 +00:00
added more unit tests for LDA and fixed a bug in the implemention of the direct page indirect mode for LDA
This commit is contained in:
parent
a8f5cc4556
commit
fadcea4c5d
2
cpu.js
2
cpu.js
|
@ -4722,7 +4722,7 @@ var LDA_direct_page_indirect = {
|
||||||
} else {
|
} else {
|
||||||
var low_byte_loc = cpu.mmu.read_byte(location);
|
var low_byte_loc = cpu.mmu.read_byte(location);
|
||||||
var high_byte_loc = cpu.mmu.read_byte(location+1);
|
var high_byte_loc = cpu.mmu.read_byte(location+1);
|
||||||
var absolute_location = high_byte_loc | low_byte_loc;
|
var absolute_location = (high_byte_loc<<8) | low_byte_loc;
|
||||||
var low_byte = cpu.mmu.read_byte(absolute_location);
|
var low_byte = cpu.mmu.read_byte(absolute_location);
|
||||||
var high_byte = cpu.mmu.read_byte(absolute_location+1);
|
var high_byte = cpu.mmu.read_byte(absolute_location+1);
|
||||||
cpu.r.a = (high_byte<<8) | low_byte;
|
cpu.r.a = (high_byte<<8) | low_byte;
|
||||||
|
|
|
@ -126,10 +126,34 @@ function test_lda() {
|
||||||
"$ff after $fd is indexed with the x register("+
|
"$ff after $fd is indexed with the x register("+
|
||||||
"which is 1) in 16-bit memory/accumulator mode.");
|
"which is 1) in 16-bit memory/accumulator mode.");
|
||||||
equals(cpu.p.m, 0, "m flag of the p status register should be 0 for "+
|
equals(cpu.p.m, 0, "m flag of the p status register should be 0 for "+
|
||||||
"16-bit memory/accumulator mdoe.");
|
"16-bit memory/accumulator mode.");
|
||||||
equals(cpu.p.e, 0, "Hidden e flag of the p status register should be 0 "+
|
equals(cpu.p.e, 0, "Hidden e flag of the p status register should be 0 "+
|
||||||
"for native mode.");
|
"for native mode.");
|
||||||
});
|
});
|
||||||
|
test("Make sure LDA indirect given a direct page address loads an 8-bit "+
|
||||||
|
"value in 8-bit memory/accumulator mode.", function() {
|
||||||
|
var cpu = new CPU_65816();
|
||||||
|
cpu.execute("18fba9ff85fea90a85ffa9068dff0aa900b2fe");
|
||||||
|
equals(cpu.r.a, 6, "The accumulator should be 6 when LDA loads an 8-bit "+
|
||||||
|
"value using an indirect address in 8-bit mode "+
|
||||||
|
"memory/accumulator mode.");
|
||||||
|
equals(cpu.p.m, 1, "m flag of the p status register should be 1 for "+
|
||||||
|
"8-bit memory/accumulator mode.");
|
||||||
|
equals(cpu.p.e, 0, "Hidden e flag of the p status register should be 0 "+
|
||||||
|
"for native mode.");
|
||||||
|
});
|
||||||
|
test("Make sure LDA indirect given a direct page address loads a 16-bit "+
|
||||||
|
"value in 16-bit memory/accumulator mode.", function() {
|
||||||
|
var cpu = new CPU_65816();
|
||||||
|
cpu.execute("18fbc220a9ff0a85fea9ffff8dff0aa90000b2fe");
|
||||||
|
equals(cpu.r.a, 0xffff, "The accumulator should be 0xffff when LDA loads "+
|
||||||
|
"a 16-bit value using an indirect address "+
|
||||||
|
"loaded from a direct page address.");
|
||||||
|
equals(cpu.p.m, 0, "m flag of the p status register should be 0 for "+
|
||||||
|
"16-bit memory/accumulator mode.");
|
||||||
|
equals(cpu.p.e, 0, "Hidden e flag of the p status register should be 0 "+
|
||||||
|
"for native mode.");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_emulation_mode() {
|
function test_emulation_mode() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user