From 9656b446f7cd8c9d85b5062285fc3117db636b42 Mon Sep 17 00:00:00 2001 From: Mark Ryan Date: Sun, 22 Sep 2024 21:35:16 +0200 Subject: [PATCH] test: fix the regcheck unit tests The format of the error message from TstCheckRegs had changed breaking some of the unit tests. Also a lot of the tests didn't disable interrupts and save and restore iy and the prime registers, which led to crashes and weird behaviour. I think I must have originally just tested this on the Next. The tests all work on a Spectrum now. Signed-off-by: Mark Ryan --- asm/tst/check.ts | 94 ++++++++++++++++++++++++++++++++++++++++++++++-- asm/tst/parse.ts | 72 +++++++++++++++++++++++++++++++++++++ 2 files changed, 164 insertions(+), 2 deletions(-) diff --git a/asm/tst/check.ts b/asm/tst/check.ts index 04edcd8..34d76d8 100644 --- a/asm/tst/check.ts +++ b/asm/tst/check.ts @@ -8,6 +8,7 @@ call TstCheckRegs ret + .TestChkBaseBad ld hl, baseBad call TstParseRegs @@ -54,40 +55,122 @@ ret .TestChkPrime + di + exx + ex af, af' + push af + push bc + push de + push hl + ex af, af' + exx + ld hl, primeGood call TstParseRegs call TstSaveRegs call modAllPrime call TstCheckRegs + + exx + ex af, af' + pop hl + pop de + pop bc + pop af + ex af, af' + exx + ei ret .TestChkPrimeBad + di + exx + ex af, af' + push af + push bc + push de + push hl + ex af, af' + exx + ld hl, baseBad call TstParseRegs call TstSaveRegs call modAllPrime call TstCheckRegs + + exx + ex af, af' + pop hl + pop de + pop bc + pop af + ex af, af' + exx + ei + ld a, c or b - jr z, badFail + jp z, badFail ld hl, primeGood call strcmp ret .TestChkMixed + di + exx + ex af, af' + push af + push bc + push de + push hl + ex af, af' + exx + ld hl, mixedGood call TstParseRegs call TstSaveRegs call modMixed call TstCheckRegs + + exx + ex af, af' + pop hl + pop de + pop bc + pop af + ex af, af' + exx + ei ret .TestChkMixedBad + di + exx + ex af, af' + push af + push bc + push de + push hl + ex af, af' + exx + ld hl, baseBad call TstParseRegs call TstSaveRegs call modMixed call TstCheckRegs + + exx + ex af, af' + pop hl + pop de + pop bc + pop af + ex af, af' + exx + ei + ld a, c or b jp z, badFail @@ -96,6 +179,13 @@ ret .strcmp + ld a, 6 + add a, c + ld c, a + ld a, 0 + adc a, b + ld b, a +.strcmpLoop ld a, (bc) cp (hl) jr nz, cmpFail @@ -103,7 +193,7 @@ jr z, cmpOk inc hl inc bc - jr strcmp + jr strcmpLoop .cmpFail ld bc, 1 ret diff --git a/asm/tst/parse.ts b/asm/tst/parse.ts index f341c6c..a45bf30 100644 --- a/asm/tst/parse.ts +++ b/asm/tst/parse.ts @@ -241,6 +241,10 @@ db 0 ret .TestCmpRegsAP + di + ex af, af' + push af + ex af, af' call TstSaveRegs ex af, af' push bc @@ -253,9 +257,17 @@ db 0 ex af, af' call TstCmpRegs ld bc, =cmpResAP+2 + ex af, af' + pop af + ex af, af' + ei jp testCmpR .TestCmpRegsFP + di + ex af, af' + push af + ex af, af' xor a call TstSaveRegs ex af, af' @@ -263,9 +275,17 @@ db 0 ex af, af' call TstCmpRegs ld bc, =cmpResFP+2 + ex af, af' + pop af + ex af, af' + ei jp testCmpR .TestCmpRegsCP + di + exx + push bc + exx call TstSaveRegs push af exx @@ -276,9 +296,17 @@ db 0 pop af call TstCmpRegs ld bc, =cmpResCP+2 + exx + pop bc + exx + ei jp testCmpR .TestCmpRegsBP + di + exx + push bc + exx call TstSaveRegs push af exx @@ -289,9 +317,17 @@ db 0 pop af call TstCmpRegs ld bc, =cmpResBP+2 + exx + pop bc + exx + ei jp testCmpR .TestCmpRegsEP + di + exx + push de + exx call TstSaveRegs push af exx @@ -302,9 +338,17 @@ db 0 pop af call TstCmpRegs ld bc, =cmpResEP+2 + exx + pop de + exx + ei jp testCmpR .TestCmpRegsDP + di + exx + push de + exx call TstSaveRegs push af exx @@ -315,9 +359,17 @@ db 0 exx call TstCmpRegs ld bc, =cmpResDP+2 + exx + pop de + exx + ei jp testCmpR .TestCmpRegsLP + di + exx + push hl + exx call TstSaveRegs push af exx @@ -328,9 +380,17 @@ db 0 pop af call TstCmpRegs ld bc, =cmpResLP+2 + exx + pop hl + exx + ei jp testCmpR .TestCmpRegsHP + di + exx + push hl + exx call TstSaveRegs push af exx @@ -341,9 +401,17 @@ db 0 pop af call TstCmpRegs ld bc, =cmpResHP+2 + exx + pop hl + exx + ei jp testCmpR .TestCmpRegsMulti + di + exx + push hl + exx xor a call TstSaveRegs push af @@ -372,6 +440,10 @@ db 0 scf call TstCmpRegs ld bc, =cmpResMulti+2 + exx + pop hl + exx + ei jp testCmpR .cmpResA