Skip to content

Commit

Permalink
test: fix the regcheck unit tests
Browse files Browse the repository at this point in the history
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 <markusdryan@gmail.com>
  • Loading branch information
markdryan committed Sep 22, 2024
1 parent d5b135d commit 9656b44
Show file tree
Hide file tree
Showing 2 changed files with 164 additions and 2 deletions.
94 changes: 92 additions & 2 deletions asm/tst/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
call TstCheckRegs
ret


.TestChkBaseBad
ld hl, baseBad
call TstParseRegs
Expand Down Expand Up @@ -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
Expand All @@ -96,14 +179,21 @@
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
or a
jr z, cmpOk
inc hl
inc bc
jr strcmp
jr strcmpLoop
.cmpFail
ld bc, 1
ret
Expand Down
72 changes: 72 additions & 0 deletions asm/tst/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ db 0
ret

.TestCmpRegsAP
di
ex af, af'
push af
ex af, af'
call TstSaveRegs
ex af, af'
push bc
Expand All @@ -253,19 +257,35 @@ 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'
scf
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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -372,6 +440,10 @@ db 0
scf
call TstCmpRegs
ld bc, =cmpResMulti+2
exx
pop hl
exx
ei
jp testCmpR

.cmpResA
Expand Down

0 comments on commit 9656b44

Please sign in to comment.