mirror of
https://github.com/JetSetIlly/Gopher2600.git
synced 2025-04-02 11:02:17 -04:00
o cpu
- fixed decimal mode subtraction and addition
This commit is contained in:
parent
913727407a
commit
37504437d4
2 changed files with 14 additions and 10 deletions
|
@ -450,6 +450,19 @@ func testSubroutineInstructions(t *testing.T, mc *cpu.CPU, mem *MockMem) {
|
|||
assert.CheckValueVCS(t, mc.SP, 255)
|
||||
}
|
||||
|
||||
func testDecimalMode(t *testing.T, mc *cpu.CPU, mem *MockMem) {
|
||||
var origin uint16
|
||||
mem.Clear()
|
||||
mc.Reset()
|
||||
|
||||
origin = mem.putInstructions(origin, 0xf8, 0xa9, 0x20, 0x38, 0xe9, 0x01)
|
||||
step(t, mc) // SED
|
||||
step(t, mc) // LDA #$20
|
||||
step(t, mc) // SEC
|
||||
step(t, mc) // SBC #$00
|
||||
assert.CheckValueVCS(t, mc.A, 0x19)
|
||||
}
|
||||
|
||||
func TestCPU(t *testing.T) {
|
||||
mem := NewMockMem()
|
||||
mc, err := cpu.New(mem)
|
||||
|
@ -467,4 +480,5 @@ func TestCPU(t *testing.T) {
|
|||
testJumps(t, mc, mem)
|
||||
testComparisonInstructions(t, mc, mem)
|
||||
testSubroutineInstructions(t, mc, mem)
|
||||
testDecimalMode(t, mc, mem)
|
||||
}
|
||||
|
|
|
@ -26,11 +26,6 @@ func (r *Register) AddDecimal(v interface{}, carry bool) (rcarry bool) {
|
|||
panic(fmt.Sprintf("decimal mode addition only supported for uint8 values with 8 bit registers"))
|
||||
}
|
||||
|
||||
// no need to do anything if operand is zero
|
||||
if val == 0 {
|
||||
return carry
|
||||
}
|
||||
|
||||
runits := uint8(r.value) & 0x0f
|
||||
rtens := (uint8(r.value) & 0xf0) >> 4
|
||||
|
||||
|
@ -69,11 +64,6 @@ func (r *Register) SubtractDecimal(v interface{}, carry bool) (rcarry bool) {
|
|||
panic(fmt.Sprintf("decimal mode subtraction only supported for uint8 values with 8 bit registers"))
|
||||
}
|
||||
|
||||
// no need to do anything if operand is zero
|
||||
if val == 0 {
|
||||
return carry
|
||||
}
|
||||
|
||||
runits := int(r.value) & 0x0f
|
||||
rtens := (int(r.value) & 0xf0) >> 4
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue