From d140590a06fbff071de23c21d3d1336b2d282691 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Mon, 14 Mar 2022 19:48:18 +0100 Subject: [PATCH] test flags when doing mov --- tester-mov.mac | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ tester.mac | 3 +++ 2 files changed, 69 insertions(+) create mode 100644 tester-mov.mac diff --git a/tester-mov.mac b/tester-mov.mac new file mode 100644 index 0000000..462479c --- /dev/null +++ b/tester-mov.mac @@ -0,0 +1,66 @@ +.EXTERN ALL + +test_mov: + MOV #what_mov,R0 + CALL print_start + +; test if flags are set when moving value + +; clear N, Z, set V and C + MOV #3,R0 + MTPS R0 + + MOV #0,R0 +; get flag-register + MFPS R1 +; mask off upper 4 bits of byte + BIC #65520.,R1 +; only Z and CARRY must be set + CMP #5.,R1 + BEQ test_mov_t1_ok +; test 1 failed + MOV #1.,R0 + JMP test_mov_fail + +test_mov_t1_ok: +test_mov_t2: +; clear all flags + MOV #0,R0 + MTPS R0 + + MOV #32768.,R0 +; get flag-register + MFPS R1 +; mask off upper 4 bits of byte + BIC #240.,R1 +; only N must be set + CMPB #8.,R1 + BEQ test_mov_t2_ok +; test 2 failed + MOV #2.,R0 + JMP test_mov_fail + +test_mov_t2_ok: + + RET + +test_mov_fail: +; print test number + CALL print_binary + +; flags are always in R1 + MOV R1,R0 + CALL print_binary + + MOV #test_mov_fail_txt,R0 + CALL print_start + RET + +test_mov_fail_txt: + .ASCII "MOV handling FAIL\r\n\x00" + + +what_mov: + .ASCII "MOV flag test\r\n\x00" + +.EVEN diff --git a/tester.mac b/tester.mac index 4e308a7..e211213 100644 --- a/tester.mac +++ b/tester.mac @@ -13,6 +13,7 @@ start: MOV #1000, R6 .INCLUDE "tester-psw.mac" .INCLUDE "tester-adc-sbc.mac" .INCLUDE "tester-addressing.mac" +.INCLUDE "tester-mov.mac" go: MOV #textstart, R0 CALL print_start @@ -27,6 +28,8 @@ go: MOV #textstart, R0 CALL test_addr + CALL test_mov + MOV #textfin, R0 CALL print_start TRAP 7