208 lines
3.1 KiB
Text
208 lines
3.1 KiB
Text
.EXTERN ALL
|
|
|
|
psw_store_retrieve:
|
|
MOV #what_psw,R0
|
|
CALL print_start
|
|
|
|
; set PSW to all bits set
|
|
MOV #65535,R1
|
|
MTPS R1
|
|
; clear PSW status bits
|
|
CLC
|
|
CLV
|
|
CLZ
|
|
CLN
|
|
; retrieve PSW and verify the flags are 0
|
|
MFPS R2
|
|
|
|
; clear currently non-relevant psw-bits
|
|
BIC #240.,R2
|
|
|
|
TSTB R2
|
|
BNE psw_store_retrieve_fail
|
|
|
|
RET
|
|
|
|
psw_store_retrieve_fail:
|
|
MOV R2,R0
|
|
CALL print_binary
|
|
|
|
MOV #psw_store_retrieve_fail_text, R0
|
|
CALL print_start
|
|
RET
|
|
|
|
clear_flags:
|
|
CLC
|
|
CLV
|
|
CLZ
|
|
CLN
|
|
RET
|
|
|
|
psw_flags_trigger:
|
|
; test zero bit
|
|
CALL clear_flags
|
|
MOV #32768.,R1
|
|
TSTB R1
|
|
BEQ psw_trigger_1_next
|
|
; store test number
|
|
MOV #1.,R2
|
|
JMP psw_trigger_fail
|
|
|
|
psw_trigger_1_next:
|
|
CALL clear_flags
|
|
MOV #128.,R1
|
|
TSTB R1
|
|
BNE psw_trigger_2_next
|
|
MOV #2.,R2
|
|
JMP psw_trigger_fail
|
|
|
|
psw_trigger_2_next:
|
|
CALL clear_flags
|
|
; test overflow bit (overflow)
|
|
MOV #127.,R1
|
|
INCB R1
|
|
BVS psw_trigger_3_next
|
|
MOV #3.,R2
|
|
JMP psw_trigger_fail
|
|
|
|
; test overflow bit (underflow)
|
|
psw_trigger_3_next:
|
|
CALL clear_flags
|
|
MOV #-128.,R1
|
|
DECB R1
|
|
BVS psw_trigger_4_next
|
|
MOV #4.,R2
|
|
JMP psw_trigger_fail
|
|
|
|
psw_trigger_4_next:
|
|
CALL clear_flags
|
|
; test minus bit
|
|
MOV #127.,R1
|
|
INCB R1
|
|
BMI psw_trigger_5_next
|
|
MOV #5.,R2
|
|
JMP psw_trigger_fail
|
|
|
|
psw_trigger_5_next:
|
|
CALL clear_flags
|
|
MOV #128.,R1
|
|
DECB R1
|
|
BPL psw_trigger_6_next
|
|
MOV #6.,R2
|
|
JMP psw_trigger_fail
|
|
|
|
psw_trigger_6_next:
|
|
CALL clear_flags
|
|
; carry flag test
|
|
MOV #128.,R1
|
|
ASLB R1
|
|
BCS psw_trigger_7_next
|
|
MOV #7.,R2
|
|
JMP psw_trigger_fail
|
|
|
|
psw_trigger_7_next:
|
|
CALL clear_flags
|
|
MOV #64.,R1
|
|
ASLB R1
|
|
BCC psw_trigger_8_next
|
|
MOV #8.,R2
|
|
JMP psw_trigger_fail
|
|
|
|
psw_trigger_8_next:
|
|
; 16 bit tests
|
|
|
|
; test zero bit
|
|
CALL clear_flags
|
|
MOV #0,R1
|
|
TST R1
|
|
BEQ psw_trigger_1_next16b
|
|
; store test number
|
|
MOV #9.,R2
|
|
JMP psw_trigger_fail
|
|
|
|
psw_trigger_1_next16b:
|
|
CALL clear_flags
|
|
MOV #32768.,R1
|
|
TST R1
|
|
BNE psw_trigger_2_next16b
|
|
MOV #10.,R2
|
|
JMP psw_trigger_fail
|
|
|
|
psw_trigger_2_next16b:
|
|
CALL clear_flags
|
|
; test overflow bit (overflow)
|
|
MOV #32767.,R1
|
|
INC R1
|
|
BVS psw_trigger_3_next16b
|
|
MOV #11.,R2
|
|
JMP psw_trigger_fail
|
|
|
|
; test overflow bit (underflow)
|
|
psw_trigger_3_next16b:
|
|
CALL clear_flags
|
|
MOV #-32768.,R1
|
|
DEC R1
|
|
BVS psw_trigger_4_next16b
|
|
MOV #12.,R2
|
|
JMP psw_trigger_fail
|
|
|
|
psw_trigger_4_next16b:
|
|
CALL clear_flags
|
|
; test minus bit
|
|
MOV #32767.,R1
|
|
INC R1
|
|
BMI psw_trigger_5_next16b
|
|
MOV #13.,R2
|
|
JMP psw_trigger_fail
|
|
|
|
psw_trigger_5_next16b:
|
|
CALL clear_flags
|
|
MOV #32768.,R1
|
|
DEC R1
|
|
BPL psw_trigger_6_next16b
|
|
MOV #14.,R2
|
|
JMP psw_trigger_fail
|
|
|
|
psw_trigger_6_next16b:
|
|
CALL clear_flags
|
|
; carry flag test
|
|
MOV #32768.,R1
|
|
ASL R1
|
|
BCS psw_trigger_7_next16b
|
|
MOV #15.,R2
|
|
JMP psw_trigger_fail
|
|
|
|
psw_trigger_7_next16b:
|
|
CALL clear_flags
|
|
MOV #16384.,R1
|
|
ASL R1
|
|
BCC psw_trigger_8_next16b
|
|
MOV #16.,R2
|
|
JMP psw_trigger_fail
|
|
|
|
psw_trigger_8_next16b:
|
|
RET
|
|
|
|
psw_trigger_fail:
|
|
CALL clear_flags
|
|
; emit test number
|
|
MOV R2,R0
|
|
CALL print_binary
|
|
; emit flags
|
|
MFPS R0
|
|
CALL print_binary
|
|
; emit text
|
|
MOV #psw_trigger_fail_text,R0
|
|
CALL print_start
|
|
RET
|
|
|
|
psw_store_retrieve_fail_text:
|
|
.ASCII "MFPS / MTPS handling FAIL\r\n\x00"
|
|
|
|
psw_trigger_fail_text:
|
|
.ASCII "PSW trigger fail\r\n\x00"
|
|
|
|
what_psw:
|
|
.ASCII "PSW handling test\r\n\x00"
|
|
|
|
.EVEN
|