RL02 verification code
This commit is contained in:
parent
4264236495
commit
846de6cac7
25 changed files with 139 additions and 1250 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -7,5 +7,5 @@ tests/*.lst
|
|||
tests/*.bin
|
||||
*.log
|
||||
work/
|
||||
tests/
|
||||
tests-work/
|
||||
build/
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
.LINK 3326
|
||||
MOV #1000,SP
|
||||
start: MOV #177564,016327
|
||||
|
||||
TRAP 7
|
||||
|
||||
make_raw
|
|
@ -1,65 +0,0 @@
|
|||
; make sure current run-mode is kernel and previous is user
|
||||
MOV #0177776,R0
|
||||
MOV #030000,(R0)
|
||||
NOP
|
||||
|
||||
; initialize kernel- and user stackpointers
|
||||
; kernel
|
||||
MOV #1000,R6
|
||||
;; user
|
||||
; MOV #0177717,R0
|
||||
; MOV #1000,(R0)
|
||||
|
||||
; user: 060000-080000 will be mapped to physical address 020000
|
||||
MOV #0177646,R0
|
||||
; 020000 / 0100 (0100 => 64 decimal)
|
||||
MOV #0200,(R0)
|
||||
NOP
|
||||
|
||||
; user: make sure write- and read-access is possible
|
||||
MOV #0177606,R0
|
||||
MOV #077406,(R0)
|
||||
|
||||
; kernel: flat mapping
|
||||
; 0-010000 -> 0
|
||||
MOV #0172340,R0
|
||||
MOV #0000,(R0)
|
||||
; 060000-0100000 -> 060000
|
||||
MOV #0172346,R0
|
||||
MOV #0600,(R0)
|
||||
NOP
|
||||
|
||||
; kernel: make sure write- and read-access is possible
|
||||
; 0-010000
|
||||
MOV #0172300,R0
|
||||
MOV #077406,(R0)
|
||||
; 060000-0100000
|
||||
MOV #0172306,R0
|
||||
MOV #077406,(R0)
|
||||
|
||||
; place a value at 020000 kernelspace which is
|
||||
; 060000 in userspace
|
||||
MOV #020000,R0
|
||||
MOV #01234,(R0)
|
||||
|
||||
; MRR0
|
||||
MOV #0177572,R0
|
||||
; enable MMU traps
|
||||
BIS #512,(R0)
|
||||
; enable MMU
|
||||
BIS #1,(R0)
|
||||
|
||||
; get word from 060000 in userspace and put that on
|
||||
; the kernel stack
|
||||
MOV #060000,R0
|
||||
MFPI (R0)
|
||||
NOP
|
||||
|
||||
; check for 01234
|
||||
MOV (SP)+,R0
|
||||
CMP #01234,R0
|
||||
NOP
|
||||
|
||||
HALT
|
||||
|
||||
make_raw
|
|
@ -1,62 +0,0 @@
|
|||
; make sure current run-mode is kernel and previous is user
|
||||
MOV #0177776,R0
|
||||
MOV #030000,(R0)
|
||||
NOP
|
||||
|
||||
; initialize kernel- and user stackpointers
|
||||
; kernel
|
||||
MOV #1000,R6
|
||||
;; user
|
||||
; MOV #0177717,R0
|
||||
; MOV #1000,(R0)
|
||||
|
||||
; user: 020000-040000 will be mapped to physical address 060000
|
||||
MOV #0177642,R0
|
||||
; 060000 / 0100 (0100 => 64 decimal)
|
||||
MOV #0600,(R0)
|
||||
NOP
|
||||
|
||||
; user: make sure write- and read-access is possible
|
||||
MOV #0177602,R0
|
||||
MOV #077406,(R0)
|
||||
|
||||
; kernel: flat mapping
|
||||
; 0-010000 -> 0
|
||||
MOV #0172340,R0
|
||||
MOV #0000,(R0)
|
||||
; 060000-0100000 -> 060000
|
||||
MOV #0172346,R0
|
||||
MOV #0600,(R0)
|
||||
NOP
|
||||
|
||||
; kernel: make sure write- and read-access is possible
|
||||
; 0-010000
|
||||
MOV #0172300,R0
|
||||
MOV #077406,(R0)
|
||||
; 060000-0100000
|
||||
MOV #0172306,R0
|
||||
MOV #077406,(R0)
|
||||
|
||||
; MRR0
|
||||
MOV #0177572,R0
|
||||
; enable MMU traps
|
||||
BIS #512,(R0)
|
||||
; enable MMU
|
||||
BIS #1,(R0)
|
||||
|
||||
; write word on stack that will be checked for to be at the
|
||||
; remapped address
|
||||
MOV #01234,-(SP)
|
||||
; this address in kernel space should be 060000 in userspace
|
||||
MOV #020000,R0
|
||||
MTPI (R0)
|
||||
NOP
|
||||
|
||||
; check for 01234 at 060000 in kernel space
|
||||
MOV #060000,R0
|
||||
CMP #01234,(R0)
|
||||
NOP
|
||||
|
||||
HALT
|
||||
|
||||
make_raw
|
138
tests/rl02test.mac
Normal file
138
tests/rl02test.mac
Normal file
|
@ -0,0 +1,138 @@
|
|||
; this is part of KEK, the PDP11/70 emulator
|
||||
|
||||
.link 1000
|
||||
start:
|
||||
mov #start, sp
|
||||
|
||||
clr r1 ; cyl
|
||||
clr r2 ; head
|
||||
clr r3 ; sector
|
||||
|
||||
write_loop:
|
||||
jsr pc,reg_to_r0
|
||||
jsr pc,set_buffer
|
||||
jsr pc,write_sector
|
||||
jsr pc,next_sector
|
||||
cmp #1,r0
|
||||
beq init_check_loop
|
||||
jmp write_loop
|
||||
|
||||
init_check_loop:
|
||||
clr r1
|
||||
clr r2
|
||||
clr r3
|
||||
|
||||
check_loop:
|
||||
jsr pc,reg_to_r0
|
||||
jsr pc,read_sector
|
||||
jsr pc,chk_buffer
|
||||
cmp #0, r0
|
||||
bne finished_failure
|
||||
jsr pc,next_sector
|
||||
cmp #1, r0
|
||||
beq finished_success
|
||||
jmp check_loop
|
||||
|
||||
finished_success:
|
||||
mov #123,R0
|
||||
halt
|
||||
|
||||
finished_failure:
|
||||
clr R0
|
||||
halt
|
||||
|
||||
write_sector:
|
||||
mov #buffer,0174402 ; bus address
|
||||
mov r0,0174404 ; disk address
|
||||
mov #-0200,0174406 ; word count (128 = 256 bytes)
|
||||
mov #012,0174400 ; go!
|
||||
write_wait:
|
||||
bit #0200,0174400
|
||||
beq write_wait
|
||||
rts pc
|
||||
|
||||
read_sector:
|
||||
mov #buffer,0174402 ; bus address
|
||||
mov r0,0174404 ; disk address
|
||||
mov #-0200,0174406 ; word count (128)
|
||||
mov #014,0174400 ; go!
|
||||
read_wait:
|
||||
bit #0200,0174400
|
||||
beq read_wait
|
||||
rts pc
|
||||
|
||||
set_buffer:
|
||||
; fill allmost all bytes with a pattern unique for this sector
|
||||
mov R0,-(SP)
|
||||
mov R5,-(SP)
|
||||
mov #0125,R0
|
||||
mov #buffer,R5
|
||||
sb_loop:
|
||||
movb r1,(r5)+
|
||||
movb r2,(r5)+
|
||||
movb r3,(r5)+
|
||||
sob r0, sb_loop
|
||||
mov (SP)+,R5
|
||||
mov (SP)+,R0
|
||||
rts pc
|
||||
|
||||
; see if the pattern is (still) there
|
||||
; return 0 if ok, else !0
|
||||
chk_buffer:
|
||||
mov R5,-(SP)
|
||||
mov #0125,R0
|
||||
mov #buffer,R5
|
||||
cb_loop:
|
||||
cmpb r1,(r5)+
|
||||
bne fail
|
||||
cmpb r2,(r5)+
|
||||
bne fail
|
||||
cmpb r3,(r5)+
|
||||
bne fail
|
||||
sob r0, cb_loop
|
||||
fail:
|
||||
mov (SP)+,R5
|
||||
rts pc
|
||||
|
||||
reg_to_r0:
|
||||
mov r4,-(sp)
|
||||
; cylinder
|
||||
mov r1,r4
|
||||
bic #0177000,r4
|
||||
ash #7,r4
|
||||
mov r4,r0
|
||||
; head
|
||||
mov r2,r4
|
||||
bic #0177776,r4
|
||||
ash #6,r4
|
||||
add r4,r0
|
||||
; sector
|
||||
mov r3,r4
|
||||
bic #0177700,r4
|
||||
add r4,r0
|
||||
mov (sp)+,r4
|
||||
rts pc
|
||||
|
||||
; sets r0 to 1 for wrap, else 0
|
||||
next_sector:
|
||||
clr r0
|
||||
inc r3
|
||||
cmp r3,#050
|
||||
blt ns_finished
|
||||
; sector wrap
|
||||
clr r3
|
||||
inc r2
|
||||
cmp r2,#02
|
||||
blt ns_finished
|
||||
clr r2
|
||||
inc r1
|
||||
cmp r1,#01000
|
||||
blt ns_finished
|
||||
clr r1
|
||||
mov #1,r0
|
||||
ns_finished:
|
||||
rts pc
|
||||
|
||||
buffer:
|
||||
; 256 bytes(!) buffer
|
||||
.blkw 0200
|
|
@ -1,50 +0,0 @@
|
|||
; in simh:
|
||||
; simh> set console telnet=3333
|
||||
; then invoke telnet to port 3333 on the simh systm
|
||||
; simh> load test.bin
|
||||
; simh> run
|
||||
|
||||
|
||||
; initialize stack pointer
|
||||
start: MOV #1000, R6
|
||||
|
||||
; store pointer to text in R0
|
||||
loop: MOV #text, R0
|
||||
CALL printstart
|
||||
JMP loop
|
||||
|
||||
; store copy of R0 on the stack
|
||||
printstart: MOV R0,-(SP)
|
||||
; store PSW (status register) on stack
|
||||
MOV R1,-(SP)
|
||||
MFPS R1
|
||||
MOV R1,-(SP)
|
||||
|
||||
; string ends with 0x00
|
||||
print: TSTB (R0)
|
||||
BEQ pdone
|
||||
|
||||
; put character in tty buffer
|
||||
MOVB (R0), @#TTYTX
|
||||
|
||||
; wait for it to be transmitted
|
||||
waittx: TSTB @#TTYST
|
||||
BPL waittx
|
||||
|
||||
INC R0
|
||||
JMP print
|
||||
|
||||
; retrieve stored r0, r1 and psw from stack
|
||||
pdone: MOV (SP)+,R1
|
||||
MTPS R1
|
||||
MOV (SP)+,R1
|
||||
|
||||
MOV (SP)+,R0
|
||||
RET
|
||||
|
||||
make_raw
|
||||
|
||||
text: .ASCII "test\r\n\x00"
|
||||
|
||||
TTYST = 177564
|
||||
TTYTX = 177566
|
|
@ -1,33 +0,0 @@
|
|||
label: CLC
|
||||
MOV #0.,R0
|
||||
ASR R0 ;
|
||||
NOP
|
||||
|
||||
CLC
|
||||
MOV #0,R1
|
||||
ASRB R1 ;
|
||||
NOP
|
||||
|
||||
CLC
|
||||
MOV #117400,R2
|
||||
ASR R2 ;
|
||||
NOP
|
||||
|
||||
CLC
|
||||
MOV #117400,R3
|
||||
ASRB R3 ;
|
||||
NOP
|
||||
|
||||
CLC
|
||||
MOV #77776,R4
|
||||
ASR R4 ;
|
||||
NOP
|
||||
|
||||
CLC
|
||||
MOV #77776,R5
|
||||
ASRB R5 ;
|
||||
NOP
|
||||
|
||||
HALT
|
||||
|
||||
make_raw
|
|
@ -1,33 +0,0 @@
|
|||
label: CLC
|
||||
MOV #0.,R0
|
||||
ASL R0 ;
|
||||
NOP
|
||||
|
||||
CLC
|
||||
MOV #0,R1
|
||||
ASLB R1 ;
|
||||
NOP
|
||||
|
||||
CLC
|
||||
MOV #117400,R2
|
||||
ASL R2 ;
|
||||
NOP
|
||||
|
||||
CLC
|
||||
MOV #117400,R3
|
||||
ASLB R3 ;
|
||||
NOP
|
||||
|
||||
CLC
|
||||
MOV #77776,R4
|
||||
ASL R4 ;
|
||||
NOP
|
||||
|
||||
CLC
|
||||
MOV #77776,R5
|
||||
ASLB R5 ;
|
||||
NOP
|
||||
|
||||
HALT
|
||||
|
||||
make_raw
|
|
@ -1,16 +0,0 @@
|
|||
mov #1000,SP
|
||||
|
||||
mov #trapfunc, @#034
|
||||
|
||||
traploop: SEC
|
||||
SEN
|
||||
SEV
|
||||
TRAP 0
|
||||
JMP traploop
|
||||
|
||||
trapfunc:
|
||||
NOP
|
||||
NOP
|
||||
RTT
|
||||
|
||||
make_raw
|
|
@ -1,33 +0,0 @@
|
|||
label: SEC
|
||||
MOV #0.,R0
|
||||
ROR R0 ;
|
||||
NOP
|
||||
|
||||
SEC
|
||||
MOV #0,R1
|
||||
RORB R1 ;
|
||||
NOP
|
||||
|
||||
SEC
|
||||
MOV #117400,R2
|
||||
ROR R2 ;
|
||||
NOP
|
||||
|
||||
SEC
|
||||
MOV #117400,R3
|
||||
RORB R3 ;
|
||||
NOP
|
||||
|
||||
SEC
|
||||
MOV #1,R4
|
||||
ROR R4 ;
|
||||
NOP
|
||||
|
||||
SEC
|
||||
MOV #1,R5
|
||||
RORB R5 ;
|
||||
NOP
|
||||
|
||||
HALT
|
||||
|
||||
make_raw
|
|
@ -1,33 +0,0 @@
|
|||
label: SEC
|
||||
MOV #0.,R0
|
||||
ROL R0 ;
|
||||
NOP
|
||||
|
||||
SEC
|
||||
MOV #0,R1
|
||||
ROLB R1 ;
|
||||
NOP
|
||||
|
||||
SEC
|
||||
MOV #117400,R2
|
||||
ROL R2 ;
|
||||
NOP
|
||||
|
||||
SEC
|
||||
MOV #117400,R3
|
||||
ROLB R3 ;
|
||||
NOP
|
||||
|
||||
SEC
|
||||
MOV #1,R4
|
||||
ROL R4 ;
|
||||
NOP
|
||||
|
||||
SEC
|
||||
MOV #1,R5
|
||||
ROLB R5 ;
|
||||
NOP
|
||||
|
||||
HALT
|
||||
|
||||
make_raw
|
|
@ -1,27 +0,0 @@
|
|||
label: MOV #0.,R0
|
||||
NEG R0 ; 0
|
||||
NOP
|
||||
|
||||
MOV #0,R1
|
||||
NEGB R1 ; 0
|
||||
NOP
|
||||
|
||||
MOV #117400,R2
|
||||
NEG R2 ; 060400
|
||||
NOP
|
||||
|
||||
MOV #117400,R3
|
||||
NEGB R3 ; 117400
|
||||
NOP
|
||||
|
||||
MOV #1,R4
|
||||
NEG R4 ; 177777
|
||||
NOP
|
||||
|
||||
MOV #1,R5
|
||||
NEGB R5 ; 000377
|
||||
NOP
|
||||
|
||||
HALT
|
||||
|
||||
make_raw
|
|
@ -1,19 +0,0 @@
|
|||
label: MOV #0.,R0
|
||||
INC R0
|
||||
NOP
|
||||
|
||||
MOV #0,R1
|
||||
INCB R1
|
||||
NOP
|
||||
|
||||
MOV #117400,R2
|
||||
INC R2
|
||||
NOP
|
||||
|
||||
MOV #117400,R3
|
||||
INCB R3
|
||||
NOP
|
||||
|
||||
HALT
|
||||
|
||||
make_raw
|
|
@ -1,19 +0,0 @@
|
|||
label: MOV #0.,R0
|
||||
DEC R0
|
||||
NOP
|
||||
|
||||
MOV #0,R1
|
||||
DECB R1
|
||||
NOP
|
||||
|
||||
MOV #117400,R2
|
||||
DEC R2
|
||||
NOP
|
||||
|
||||
MOV #117400,R3
|
||||
DECB R3
|
||||
NOP
|
||||
|
||||
HALT
|
||||
|
||||
make_raw
|
|
@ -1,19 +0,0 @@
|
|||
label: MOV #0.,R0
|
||||
COM R0 ; 65535
|
||||
NOP
|
||||
|
||||
MOV #0,R1
|
||||
COMB R1 ; 255
|
||||
NOP
|
||||
|
||||
MOV #117400,R2
|
||||
COM R2 ; 24831
|
||||
NOP
|
||||
|
||||
MOV #117400,R3
|
||||
COMB R3 ; 40959
|
||||
NOP
|
||||
|
||||
HALT
|
||||
|
||||
make_raw
|
|
@ -1,8 +0,0 @@
|
|||
label: MOV #2000,SP
|
||||
NOP
|
||||
INC SP
|
||||
NOP
|
||||
DEC SP
|
||||
NOP
|
||||
|
||||
make_raw
|
|
@ -1,5 +0,0 @@
|
|||
NOP
|
||||
label: .DW 077700
|
||||
NOP
|
||||
|
||||
make_raw
|
|
@ -1,4 +0,0 @@
|
|||
.DW 072527
|
||||
.DW 000000
|
||||
|
||||
make_raw
|
|
@ -1,110 +0,0 @@
|
|||
.EXTERN ALL
|
||||
|
||||
test_adc:
|
||||
MOV #what_adc,R0
|
||||
CALL print_start
|
||||
|
||||
; initial value
|
||||
MOV #32769.,R0
|
||||
; number of additions
|
||||
MOV #257.,R1
|
||||
|
||||
test_adc_loop:
|
||||
ADD #1003.,R0
|
||||
ADC R0
|
||||
|
||||
MFPS R2
|
||||
BIC #65520.,R2
|
||||
ADD R2,R0
|
||||
|
||||
DEC R1
|
||||
TST R1
|
||||
BNE test_adc_loop
|
||||
|
||||
CMP #29424.,R0
|
||||
BNE test_adc_failed
|
||||
|
||||
; test 8 bit
|
||||
MOV #32769.,R0
|
||||
MOV #257.,R1
|
||||
|
||||
test_adc_loop8b:
|
||||
ADD #13.,R0
|
||||
ADCB R0
|
||||
|
||||
MFPS R2
|
||||
BIC #65520.,R2
|
||||
ADD R2,R0
|
||||
|
||||
DEC R1
|
||||
TST R1
|
||||
BNE test_adc_loop8b
|
||||
|
||||
CMP #36878.,R0
|
||||
BNE test_adc_failed
|
||||
|
||||
RET
|
||||
|
||||
test_adc_failed:
|
||||
MOV #adc_fail_text,R0
|
||||
CALL print_start
|
||||
RET
|
||||
|
||||
adc_fail_text:
|
||||
.ASCII "ADC handling FAIL\r\n\x00"
|
||||
.EVEN
|
||||
|
||||
test_sbc:
|
||||
; initial value
|
||||
MOV #32769.,R0
|
||||
; number of additions
|
||||
MOV #257.,R1
|
||||
|
||||
test_sbc_loop:
|
||||
SUB #1003.,R0
|
||||
SBC R0
|
||||
|
||||
MFPS R2
|
||||
BIC #65520.,R2
|
||||
SUB R2,R0
|
||||
|
||||
DEC R1
|
||||
TST R1
|
||||
BNE test_sbc_loop
|
||||
|
||||
CMP #36106.,R0
|
||||
BNE test_sbc_failed
|
||||
|
||||
; test 8 bit
|
||||
MOV #32769.,R0
|
||||
MOV #257.,R1
|
||||
|
||||
test_sbc_loop8b:
|
||||
SUB #13.,R0
|
||||
SBCB R0
|
||||
|
||||
MFPS R2
|
||||
BIC #65520.,R2
|
||||
SUB R2,R0
|
||||
|
||||
DEC R1
|
||||
TST R1
|
||||
BNE test_sbc_loop8b
|
||||
|
||||
CMP #28652.,R0
|
||||
BNE test_sbc_failed
|
||||
|
||||
RET
|
||||
|
||||
test_sbc_failed:
|
||||
MOV #sbc_fail_text,R0
|
||||
CALL print_start
|
||||
RET
|
||||
|
||||
sbc_fail_text:
|
||||
.ASCII "SBC handling FAIL\r\n\x00"
|
||||
|
||||
what_adc:
|
||||
.ASCII "ADC/SBC test\r\n\x00"
|
||||
|
||||
.EVEN
|
|
@ -1,195 +0,0 @@
|
|||
.EXTERN ALL
|
||||
|
||||
test_addr_0:
|
||||
MOV #what_address,R0
|
||||
CALL print_start
|
||||
|
||||
; address mode 0
|
||||
; b1010101001010101
|
||||
; 16 bit put/get
|
||||
MOV #43605.,R0
|
||||
CMP #43605.,R0
|
||||
BEQ test_addr_0a_ok
|
||||
MOV #1.,R0
|
||||
JMP test_addr_fail
|
||||
|
||||
test_addr_0a_ok:
|
||||
; 8 bit put / 16 bit get, should sign extend
|
||||
MOVB #240.,R0
|
||||
CMP #65520.,R0
|
||||
BEQ test_addr_0b_ok
|
||||
MOV #2.,R0
|
||||
JMP test_addr_fail
|
||||
|
||||
test_addr_0b_ok:
|
||||
; 8 bit put / 16 bit get, should sign extend
|
||||
MOVB #127.,R0
|
||||
CMP #127.,R0
|
||||
BEQ test_addr_0c_ok
|
||||
MOV #3.,R0
|
||||
JMP test_addr_fail
|
||||
|
||||
test_addr_0c_ok:
|
||||
test_addr_1:
|
||||
; address mode 1
|
||||
; indirect get 16 bit
|
||||
MOV #v1234,R0
|
||||
MOV (R0),R1
|
||||
CMP #1234.,R1
|
||||
BEQ test_addr_1a_ok
|
||||
MOV #4.,R0
|
||||
JMP test_addr_fail
|
||||
|
||||
test_addr_1a_ok:
|
||||
; indirect get 8 bit, sign extended
|
||||
MOV #v1234,R0
|
||||
MOVB (R0),R1
|
||||
CMP #65490.,R1
|
||||
BEQ test_addr_1b_ok
|
||||
MOV #5.,R0
|
||||
JMP test_addr_fail
|
||||
|
||||
test_addr_1b_ok:
|
||||
; indirect get 16 bit
|
||||
MOV #v1234,R0
|
||||
MOVB (R0),R1
|
||||
CMP #1234.,R1
|
||||
BNE test_addr_1c_ok
|
||||
MOV #6.,R0
|
||||
JMP test_addr_fail
|
||||
|
||||
test_addr_1c_ok:
|
||||
test_addr_2:
|
||||
; address mode 2
|
||||
; value did not change
|
||||
MOV #v1234,R0
|
||||
MOV (R0)+,R1
|
||||
CMP #1234.,R1
|
||||
BEQ test_addr_2a1_ok
|
||||
MOV #7.,R0
|
||||
JMP test_addr_fail
|
||||
;
|
||||
test_addr_2a1_ok:
|
||||
; address increased 2 bytes
|
||||
MOV #v1234after,R2
|
||||
CMP R0,R2
|
||||
BEQ test_addr_2a2_ok
|
||||
MOV #8.,R0
|
||||
JMP test_addr_fail
|
||||
|
||||
test_addr_2a2_ok:
|
||||
; value did not change
|
||||
MOV #v1234,R0
|
||||
MOVB (R0)+,R1
|
||||
CMPB #210.,R1
|
||||
BEQ test_addr_2b1_ok
|
||||
MOV #9.,R0
|
||||
JMP test_addr_fail
|
||||
|
||||
test_addr_2b1_ok:
|
||||
; test if this pdp-11 has the hw-bug
|
||||
MOV #v1234,R0
|
||||
MOV (R0)+,R0
|
||||
CMP #1234.,R0
|
||||
BEQ test_addr_2b2_ok
|
||||
MOV #10.,R0
|
||||
JMP test_addr_fail
|
||||
|
||||
test_addr_2b2_ok:
|
||||
test_addr_3:
|
||||
; verify contents of addr1234 first
|
||||
MOV addr1234,r0
|
||||
CMP #1234.,(R0)
|
||||
BEQ test_addr_3b_verify_ok
|
||||
MOV #12.,R0
|
||||
JMP test_addr_fail
|
||||
|
||||
test_addr_3b_verify_ok:
|
||||
MOV @(R0)+,R1
|
||||
MOV #v1234after,R2
|
||||
CMP R0,R2
|
||||
BEQ test_addr_3b2_ok
|
||||
MOV #13.,R0
|
||||
JMP test_addr_fail
|
||||
|
||||
test_addr_3b2_ok:
|
||||
test_addr_4:
|
||||
|
||||
; TODO
|
||||
; address mode 4
|
||||
; value did not change
|
||||
MOV #v1234,R0
|
||||
MOV -(R0),R1
|
||||
CMP #4455.,R1
|
||||
BEQ test_addr_4a1_ok
|
||||
MOV #14.,R0
|
||||
JMP test_addr_fail
|
||||
;
|
||||
test_addr_4a1_ok:
|
||||
; address drecreased 2 bytes
|
||||
MOV #v4455before,R2
|
||||
CMP R0,R2
|
||||
BEQ test_addr_4a2_ok
|
||||
MOV #15.,R0
|
||||
JMP test_addr_fail
|
||||
|
||||
test_addr_4a2_ok:
|
||||
; value did not change
|
||||
MOV #v1234,R0
|
||||
MOVB -(R0),R1
|
||||
CMPB #17.,R1
|
||||
BEQ test_addr_4a3_ok
|
||||
MOV #16.,R0
|
||||
JMP test_addr_fail
|
||||
|
||||
test_addr_4a3_ok:
|
||||
test_addr_5:
|
||||
; TODO
|
||||
|
||||
|
||||
test_addr_6:
|
||||
MOV #v1234,R0
|
||||
MOV 2(R0),R1
|
||||
CMP #4321.,R1
|
||||
BEQ test_addr_6_ok
|
||||
MOV #17.,R0
|
||||
JMP test_addr_fail
|
||||
|
||||
test_addr_6_ok:
|
||||
test_addr_7:
|
||||
; index deferred
|
||||
MOV #addr1234,R0
|
||||
MOV @2(R0),R1
|
||||
CMP #4321.,R1
|
||||
BEQ test_addr_7_ok
|
||||
MOV #18.,R0
|
||||
JMP test_addr_fail
|
||||
|
||||
test_addr_7_ok:
|
||||
RET
|
||||
|
||||
test_addr_fail:
|
||||
CALL print_binary
|
||||
|
||||
MOV #test_addr_fail_txt,R0
|
||||
CALL print_start
|
||||
RET
|
||||
|
||||
test_addr_fail_txt:
|
||||
.ASCII "addressing handling FAIL\r\n\x00"
|
||||
|
||||
what_address:
|
||||
.ASCII "addressing tests\r\n\x00"
|
||||
|
||||
.EVEN
|
||||
|
||||
v4455before: DW 4455.
|
||||
v1234: DW 1234.
|
||||
v1234after: DW 4321.
|
||||
|
||||
addr1234: DW v1234
|
||||
addr1234after: DW v1234after
|
||||
|
||||
test_addr:
|
||||
CALL test_addr_0
|
||||
RET
|
|
@ -1,50 +0,0 @@
|
|||
.EXTERN ALL
|
||||
|
||||
test_bge:
|
||||
MOV #what_bge,R0
|
||||
CALL print_start
|
||||
|
||||
test_bge_1:
|
||||
; initialize flags
|
||||
MOV #8.,R0
|
||||
MTPS R0
|
||||
|
||||
; should not jump
|
||||
BGE test_bge_1_fail
|
||||
JMP test_bge_2
|
||||
|
||||
test_bge_1_fail:
|
||||
MOV #1.,R0
|
||||
JMP test_bge_fail
|
||||
|
||||
test_bge_2:
|
||||
MOV #10.,R0
|
||||
MTPS R0
|
||||
BGE test_bge_2_ok
|
||||
|
||||
MOV #2.,R0
|
||||
JMP test_bge_fail
|
||||
|
||||
test_bge_2_ok:
|
||||
RET
|
||||
|
||||
test_bge_fail:
|
||||
; print test number
|
||||
CALL print_binary
|
||||
|
||||
; flags are always (for this tester) in R2
|
||||
MOV R2,R0
|
||||
CALL print_binary
|
||||
|
||||
MOV #test_bge_fail_txt,R0
|
||||
CALL print_start
|
||||
RET
|
||||
|
||||
test_bge_fail_txt:
|
||||
.ASCII "BGE handling FAIL\r\n\x00"
|
||||
|
||||
|
||||
what_bge:
|
||||
.ASCII "BGE test\r\n\x00"
|
||||
|
||||
.EVEN
|
|
@ -1,66 +0,0 @@
|
|||
.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 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 bits of byte
|
||||
BIC #65520.,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
|
|
@ -1,208 +0,0 @@
|
|||
.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
|
|
@ -1,66 +0,0 @@
|
|||
.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
|
121
tests/tester.mac
121
tests/tester.mac
|
@ -1,121 +0,0 @@
|
|||
; in simh:
|
||||
; simh> set console telnet=3333
|
||||
; then invoke telnet to port 3333 on the simh systm
|
||||
; simh> load test.bin
|
||||
; simh> run
|
||||
|
||||
.EXTERN ALL
|
||||
|
||||
; initialize stack pointer
|
||||
start: MOV #1000, R6
|
||||
JMP go
|
||||
|
||||
.INCLUDE "tester-psw.mac"
|
||||
.INCLUDE "tester-adc-sbc.mac"
|
||||
.INCLUDE "tester-addressing.mac"
|
||||
.INCLUDE "tester-mov.mac"
|
||||
.INCLUDE "tester-tst.mac"
|
||||
.INCLUDE "tester-bge.mac"
|
||||
|
||||
go: MOV #textstart, R0
|
||||
CALL print_start
|
||||
|
||||
CALL psw_store_retrieve
|
||||
|
||||
CALL psw_flags_trigger
|
||||
|
||||
CALL test_adc
|
||||
|
||||
CALL test_sbc
|
||||
|
||||
CALL test_addr
|
||||
|
||||
CALL test_mov
|
||||
|
||||
CALL test_tst
|
||||
|
||||
CALL test_bge
|
||||
|
||||
MOV #textfin, R0
|
||||
CALL print_start
|
||||
TRAP 7
|
||||
|
||||
; store copy of R0 on the stack
|
||||
print_start: MOV R0,-(SP)
|
||||
; store PSW (status register) on stack
|
||||
MFPS -(SP)
|
||||
|
||||
; string ends with 0x00
|
||||
print: TSTB (R0)
|
||||
BEQ pdone
|
||||
|
||||
; put character in tty buffer
|
||||
MOVB (R0), @#TTYTX
|
||||
|
||||
; wait for it to be transmitted
|
||||
waittx: TSTB @#TTYST
|
||||
BPL waittx
|
||||
|
||||
INC R0
|
||||
JMP print
|
||||
|
||||
; retrieve stored r0, r1 and psw from stack
|
||||
pdone: MTPS (SP)+
|
||||
|
||||
MOV (SP)+,R0
|
||||
RET
|
||||
|
||||
print_binary:
|
||||
MFPS -(SP)
|
||||
MOV R0,-(SP)
|
||||
MOV R1,-(SP)
|
||||
; 16 bits in a word
|
||||
MOV #16.,R1
|
||||
|
||||
print_bit:
|
||||
ASL R0
|
||||
BCS print_1
|
||||
waittx0:
|
||||
TSTB @#TTYST
|
||||
BPL waittx0
|
||||
MOVB #48., @#TTYTX
|
||||
BR print_next_bit
|
||||
print_1:
|
||||
waittx1:
|
||||
TSTB @#TTYST
|
||||
BPL waittx1
|
||||
MOVB #49., @#TTYTX
|
||||
BR print_next_bit
|
||||
|
||||
print_next_bit:
|
||||
; keep track of the number of bits emitted
|
||||
DEC R1
|
||||
TST R1
|
||||
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)+,R0
|
||||
MTPS (SP)+
|
||||
RET
|
||||
|
||||
make_raw
|
||||
|
||||
textstart: .ASCII "tester running...\r\n\x00"
|
||||
textfin: .ASCII "tester finished\r\n\x00"
|
||||
.EVEN
|
||||
|
||||
textbuffer: .BLKB 256.
|
||||
|
||||
TTYST = 177564
|
||||
TTYTX = 177566
|
Loading…
Add table
Reference in a new issue