mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-08 14:25:05 +00:00
Added test for EX (SP), rp, which passes.
This commit is contained in:
@@ -25,6 +25,7 @@ class Z80MemptrTests: XCTestCase {
|
|||||||
|
|
||||||
// LD A, (addr)
|
// LD A, (addr)
|
||||||
func testLDAnn() {
|
func testLDAnn() {
|
||||||
|
// MEMPTR = addr+1
|
||||||
var program: [UInt8] = [
|
var program: [UInt8] = [
|
||||||
0x3a, 0x00, 0x00
|
0x3a, 0x00, 0x00
|
||||||
]
|
]
|
||||||
@@ -46,6 +47,7 @@ class Z80MemptrTests: XCTestCase {
|
|||||||
|
|
||||||
// LD A, (rp)
|
// LD A, (rp)
|
||||||
func testLDArp() {
|
func testLDArp() {
|
||||||
|
// MEMPTR = rp+1
|
||||||
let bcProgram: [UInt8] = [
|
let bcProgram: [UInt8] = [
|
||||||
0x0a
|
0x0a
|
||||||
]
|
]
|
||||||
@@ -79,6 +81,7 @@ class Z80MemptrTests: XCTestCase {
|
|||||||
|
|
||||||
// LD rp, (addr)
|
// LD rp, (addr)
|
||||||
func testLDnnrp() {
|
func testLDnnrp() {
|
||||||
|
// MEMPTR = addr+1
|
||||||
var hlBaseProgram: [UInt8] = [
|
var hlBaseProgram: [UInt8] = [
|
||||||
0x22, 0x00, 0x00
|
0x22, 0x00, 0x00
|
||||||
]
|
]
|
||||||
@@ -135,10 +138,34 @@ class Z80MemptrTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO:
|
// EX (SP), rp
|
||||||
EX (SP),rp
|
func testEXSPrp() {
|
||||||
MEMPTR = rp value after the operation
|
// MEMPTR = rp at end
|
||||||
*/
|
var hlProgram: [UInt8] = [
|
||||||
|
0xe3, 0x00, 0x00, 0x00
|
||||||
|
]
|
||||||
|
var ixProgram: [UInt8] = [
|
||||||
|
0xdd, 0xe3, 0x00, 0x00
|
||||||
|
]
|
||||||
|
var iyProgram: [UInt8] = [
|
||||||
|
0xfd, 0xe3, 0x00, 0x00
|
||||||
|
]
|
||||||
|
|
||||||
|
machine.setValue(2, for: .stackPointer)
|
||||||
|
|
||||||
|
for addr in 0 ..< 65536 {
|
||||||
|
hlProgram[2] = UInt8(addr & 0x00ff)
|
||||||
|
hlProgram[3] = UInt8(addr >> 8)
|
||||||
|
ixProgram[2] = UInt8(addr & 0x00ff)
|
||||||
|
ixProgram[3] = UInt8(addr >> 8)
|
||||||
|
iyProgram[2] = UInt8(addr & 0x00ff)
|
||||||
|
iyProgram[3] = UInt8(addr >> 8)
|
||||||
|
|
||||||
|
XCTAssertEqual(test(program: hlProgram, length: 19, initialValue: 0xffff), UInt16(addr))
|
||||||
|
XCTAssertEqual(test(program: ixProgram, length: 23, initialValue: 0xffff), UInt16(addr))
|
||||||
|
XCTAssertEqual(test(program: iyProgram, length: 23, initialValue: 0xffff), UInt16(addr))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO:
|
/* TODO:
|
||||||
ADD/ADC/SBC rp1,rp2
|
ADD/ADC/SBC rp1,rp2
|
||||||
@@ -187,8 +214,9 @@ class Z80MemptrTests: XCTestCase {
|
|||||||
when BC <> 1: MEMPTR = PC + 1, where PC = instruction address
|
when BC <> 1: MEMPTR = PC + 1, where PC = instruction address
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// CPI
|
||||||
func testCPI() {
|
func testCPI() {
|
||||||
// CPI: MEMPTR = MEMPTR + 1
|
// MEMPTR = MEMPTR + 1
|
||||||
let program: [UInt8] = [
|
let program: [UInt8] = [
|
||||||
0xed, 0xa1
|
0xed, 0xa1
|
||||||
]
|
]
|
||||||
@@ -202,8 +230,9 @@ class Z80MemptrTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CPD
|
||||||
func testCPD() {
|
func testCPD() {
|
||||||
// CPD: MEMPTR = MEMPTR - 1
|
// MEMPTR = MEMPTR - 1
|
||||||
let program: [UInt8] = [
|
let program: [UInt8] = [
|
||||||
0xed, 0xa9
|
0xed, 0xa9
|
||||||
]
|
]
|
||||||
|
Reference in New Issue
Block a user