psw test & emit binary fixes

This commit is contained in:
folkert van heusden 2022-03-13 13:42:47 +01:00
parent 33358346a3
commit e207093572
2 changed files with 65 additions and 48 deletions

41
tester-psw.mac Normal file
View file

@ -0,0 +1,41 @@
.EXTERN ALL
psw_store_retrieve:
; 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_fail_text, R0
CALL print_start
RET
psw_flags_trigger:
CLC
CLV
CLZ
CLN
; TODO
RET
psw_fail_text: .ASCII "MFPS / MTPS handling FAIL\r\n\x00"

View file

@ -4,11 +4,15 @@
; simh> load test.bin ; simh> load test.bin
; simh> run ; simh> run
.EXTERN ALL
; initialize stack pointer ; initialize stack pointer
start: MOV #1000, R6 start: MOV #1000, R6
JMP go
MOV #textstart, R0 .INCLUDE "tester-psw.mac"
go: MOV #textstart, R0
CALL print_start CALL print_start
CALL psw_store_retrieve CALL psw_store_retrieve
@ -19,46 +23,6 @@ start: MOV #1000, R6
CALL print_start CALL print_start
TRAP 7 TRAP 7
psw_store_retrieve:
; 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 uninteresting flags
BIC #4,R2
BIC #5,R2
BIC #6,R2
BIC #7,R2
TSTB R2
BNE psw_store_retrieve_fail
RET
psw_store_retrieve_fail:
MOV R2,R0
CALL print_binary
MOV #psw_fail_text, R0
CALL print_start
RET
psw_flags_trigger:
CLC
CLV
CLZ
CLN
RET
psw_fail_text: .ASCII "MFPS / MTPS handling FAIL\r\n\x00"
; store copy of R0 on the stack ; store copy of R0 on the stack
print_start: MOV R0,-(SP) print_start: MOV R0,-(SP)
; store PSW (status register) on stack ; store PSW (status register) on stack
@ -85,35 +49,47 @@ pdone: MTPS (SP)+
RET RET
print_binary: print_binary:
MFPS -(SP)
MOV R0,-(SP) MOV R0,-(SP)
MOV R1,-(SP) MOV R1,-(SP)
; 8 bits in a byte ; 8 bits in a byte
MOV #8.,R1 MOV #8.,R1
print_bit: print_bit:
BIT #0,R0 ASLB R0
BEQ print_1: BCS print_1
waittx0: waittx0:
TSTB @#TTYST TSTB @#TTYST
BPL waittx0 BPL waittx0
MOVB #33, @#TTYTX MOVB #48., @#TTYTX
BR print_next_bit BR print_next_bit
print_1: print_1:
waittxt1: waittx1:
TSTB @#TTYST TSTB @#TTYST
BPL waittx1 BPL waittx1
MOVB #34, @#TTYTX MOVB #49., @#TTYTX
BR print_next_bit
print_next_bit: print_next_bit:
; move R0 contents to the next bit
ASR R0
; keep track of the number of bits emitted ; keep track of the number of bits emitted
DEC R1 DEC R1
TST R1 TST R1
BNE print_bit BNE print_bit
; emit seperator
bit_seperator:
TSTB @#TTYST
BPL bit_seperator
MOVB #32., @#TTYTX
; for some reason the last character is not printed in simh unless repeated
bit_seperator2:
TSTB @#TTYST
BPL bit_seperator2
MOVB #32., @#TTYTX
MOV (SP)+,R1 MOV (SP)+,R1
MOV (SP)+,R0 MOV (SP)+,R0
MTPS (SP)+
RET RET
make_raw make_raw