From 9ebb1aa0c92c3e1b66cde3ea503f55472071f849 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Mon, 14 Mar 2022 20:01:24 +0100 Subject: [PATCH] TST test --- tester-mov.mac | 6 ++--- tester-tst.mac | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ tester.mac | 3 +++ 3 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 tester-tst.mac diff --git a/tester-mov.mac b/tester-mov.mac index 462479c..58ac6b1 100644 --- a/tester-mov.mac +++ b/tester-mov.mac @@ -13,7 +13,7 @@ test_mov: MOV #0,R0 ; get flag-register MFPS R1 -; mask off upper 4 bits of byte +; mask off upper bits of byte BIC #65520.,R1 ; only Z and CARRY must be set CMP #5.,R1 @@ -31,8 +31,8 @@ test_mov_t2: MOV #32768.,R0 ; get flag-register MFPS R1 -; mask off upper 4 bits of byte - BIC #240.,R1 +; mask off upper bits of byte + BIC #65520.,R1 ; only N must be set CMPB #8.,R1 BEQ test_mov_t2_ok diff --git a/tester-tst.mac b/tester-tst.mac new file mode 100644 index 0000000..6bcdd38 --- /dev/null +++ b/tester-tst.mac @@ -0,0 +1,66 @@ +.EXTERN ALL + +test_tst: + MOV #what_tst,R0 + CALL print_start + +test_tst_1: +; initialize flags + MOV #15.,R0 + MTPS R0 + +; test TST when value is 0 + MOV #0,R1 + TST R1 +; retrieve flags + MFPS R2 +; mask off upper bits of byte + BIC #65520.,R2 + CMP #4.,R2 + BEQ test_tst_1_ok + + MOV #1.,R0 + JMP test_tst_fail + +test_tst_1_ok: +test_tst_2: +; initialize flags + MOV #15.,R0 + MTPS R0 + +; test TST when value is !0 + MOV #32768.,R1 + TST R1 +; retrieve flags + MFPS R2 +; mask off upper bits of byte + BIC #65520.,R2 + CMP #8.,R2 + BEQ test_tst_2_ok + + MOV #2.,R0 + JMP test_tst_fail + +test_tst_2_ok: + RET + +test_tst_fail: +; print test number + CALL print_binary + +; flags are always (for this tester) in R2 + MOV R2,R0 + CALL print_binary + + MOV #test_tst_fail_txt,R0 + CALL print_start + RET + +test_tst_fail_txt: + .ASCII "TST handling FAIL\r\n\x00" + + +what_tst: + .ASCII "TST test\r\n\x00" + +.EVEN diff --git a/tester.mac b/tester.mac index e211213..efbbdaf 100644 --- a/tester.mac +++ b/tester.mac @@ -14,6 +14,7 @@ start: MOV #1000, R6 .INCLUDE "tester-adc-sbc.mac" .INCLUDE "tester-addressing.mac" .INCLUDE "tester-mov.mac" +.INCLUDE "tester-tst.mac" go: MOV #textstart, R0 CALL print_start @@ -30,6 +31,8 @@ go: MOV #textstart, R0 CALL test_mov + CALL test_tst + MOV #textfin, R0 CALL print_start TRAP 7