1
0
mirror of https://github.com/wfjm/w11.git synced 2026-02-01 06:33:07 +00:00

BUGFIX: cc state unchanged after abort - mtp/mfp case

- rtl/w11a/
  - pdp11_dpath.vhd: use c_dpath_dsrc_src,c_dpath_ddst_dst
  - pdp11_sequencer.vhd: BUGFIX: cc state unchanged after abort (mtp/mfp)
- tools/tcode
  - cpu_basics.mac: add F4.1-6
  - cpu_details.mac: add B3.2-3
This commit is contained in:
wfjm
2023-01-02 16:27:46 +01:00
parent b59d545956
commit 26daa71634
8 changed files with 475 additions and 28 deletions

View File

@@ -1,10 +1,10 @@
; $Id: cpu_basics.mac 1329 2022-12-11 17:28:28Z mueller $
; $Id: cpu_basics.mac 1342 2023-01-02 15:18:19Z mueller $
; SPDX-License-Identifier: GPL-3.0-or-later
; Copyright 2015-2022 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
; Copyright 2015-2023 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
;
; Revision History:
; Date Rev Version Comment
; 2022-12-06 1324 1.0 Initial version
; 2023-01-02 1342 1.0 Initial version
; 2015-08-30 710 0.1 First draft
;
; Test CPU basics: most instructions except traps, EIS and FPP
@@ -13,7 +13,7 @@
; Section C: binary instructions (word)
; Section D: unary instructions (byte)
; Section E: binary instructions (byte)
; Section F: miscellaneous (spl, reset, bpt,...)
; Section F: miscellaneous (spl, reset, bpt, m*p*, ...)
;
.include |lib/tcode_std_base.mac|
.include |lib/defs_kwl.mac|
@@ -2964,7 +2964,7 @@ te0501: clr cp.psw
;
9999$: iot ; end of test E5.1
;
; Section F: miscellaneous (spl, reset) ======================================
; Section F: miscellaneous (spl, reset, bpt, m*p*, ...) ======================
; F1 spl
; F1.1 spl in kernel mode
; F1.2 spl in supervisor and user mode
@@ -2973,6 +2973,13 @@ te0501: clr cp.psw
; F2.2 reset in supervisor and user mode
; F2.3 reset settling time
; F3 trap instructions: bpt,iot,emt,trap
; F4 MTP* and MFP* basics
; F4.1 MTP* with all address mode
; F4.2 MTP* and cc for reg dst
; F4.3 MTP* and cc for mem dst
; F4.4 MFP* with all address modes
; F4.5 MFP* and cc for reg dst
; F4.6 MFP* and cc for mem dst
;
; Test F1: spl ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; This sub-section verifies
@@ -3216,10 +3223,360 @@ tf0301: mov #v..iot+2,v..iot ; block iot handler
;
9999$: iot ; end of test F3.1
;
; Test F4: MTP* and MFP* basics ++++++++++++++++++++++++++++++++++++++++++++++
; This sub-section verifies
; x xxx xxx xxx xxx xxx NZVC Instruction / Remark
; 0 000 110 101 ddd ddd NZ0- MFPI
; 0 000 110 110 ddd ddd NZ0- MTPI
; 1 000 110 101 ddd ddd NZ0- MFPD
; 1 000 110 110 ddd ddd NZ0- MTPD
;
; Only basic read-write functionality tested with cm=pm=kernel with MMU off.
; Only M*PI is tested, with MMU off there is not difference between I and D.
; All destination address modes are verified.
; This also verifies the dsta flow.
;
; Test F4.1 MTP* with all address modes ++++++++++++++++++++++++++++++
; Tests mode 0-7, and the special cases sp, (sp), -(sp), @(sp)+, n(sp),
;
tf0401: clr cp.psw
mov #123,r0 ; src for MOV
mov #100$,r1 ; dst for (r1),(r1)+,-(r1),0(r1)
mov #200$,r2 ; dst for @(r2)+,@-(r2),@0(r2)
mov r1,r3 ; ptr to dst
;
clr r5
push r0
mtpi r5 ; mode 0 - general purpose register
hcmpeq r0,r5 ; check dst
;
inc r0
push r0
mtpi (r1) ; mode 1
hcmpeq r0,(r3) ; check dst
;
inc r0
push r0
mtpi (r1)+ ; mode 2
hcmpeq #100$+2,r1 ; check r1
hcmpeq r0,(r3) ; check dst
;
inc r0
push r0
mtpi -(r1) ; mode 4
hcmpeq #100$,r1 ; check r1
hcmpeq r0,(r3) ; check dst
;
inc r0
push r0
mtpi 0(r1) ; mode 6
hcmpeq r0,(r3) ; check dst
;
inc r0
push r0
mtpi @(r2)+ ; mode 3
hcmpeq #200$+2,r2 ; check r2
hcmpeq r0,(r3) ; check dst
;
inc r0
push r0
mtpi @-(r2) ; mode 5
hcmpeq #200$,r2 ; check r2
hcmpeq r0,(r3) ; check dst
;
inc r0
push r0
mtpi @0(r2) ; mode 7
hcmpeq r0,(r3) ; check dst
;
hcmpeq #stack,sp ; check SP normal
;
; check SP special cases
;
inc r0
push r0
mtpi sp ; mode 0: SP as target
hcmpeq r0,sp ; check SP
;
mov #stack-2,sp ; ptr to writable stack word
inc r0
push r0
mtpi (sp) ; mode 1: (SP) as target
hcmpeq #stack-2,sp ; check SP
hcmpeq r0,stack-2 ; was stack modified ?
mov #stack,sp ; SP to normal
;
inc r0
push r0
mtpi -(sp) ; mode 4: -(SP) as target
hcmpeq #stack-2,sp ; check SP
hcmpeq r0,stack-2 ; was stack modified ?
tst (sp)+ ; pop value
;
inc r0
push #100$ ; push address - read 2nd
push r0 ; push value - read 1st
mtpi @(sp)+ ; mode 3: @(SP)+ as target
hcmpeq r0,(r3) ; check dst
;
inc r0
push r0
mtpi -2(sp) ; mode 6 - n(SP) as target
hcmpeq #stack,sp ; check SP
hcmpeq r0,stack-2 ; was stack modified ?
;
br 9999$
;
100$: .word 0 ; dst target
200$: .word 100$ ; ptr to dst
;
9999$: iot ; end of test F4.1
;
; Test F4.2 MTP* and cc for reg dst ++++++++++++++++++++++++++++++++++
;
tf0402: mov #cp.psw,r4
clr (r4)
;
clr -(sp) ; zero value
ccc
mtpi r5
hcmpeq #cp0z00,(r4) ; check N=0,Z=1
;
push #1. ; positive value
ccc
<sen!sez> ; NZ=1
mtpi r5
hcmpeq #cp0000,(r4) ; check N=0,Z=0
;
push #-1. ; negative value
ccc
mtpi r5
hcmpeq #cpn000,(r4) ; check N=1,Z=0
;
push #1. ; positive value
sec ; C=1
mtpi r5
hcmpeq #cp000c,(r4) ; check C=1 kept
;
push #1. ; positive word
scc ; NZVC=1
mtpi r5
hcmpeq #cp000c,(r4) ; check C kept, NZV cleared
;
9999$: iot ; end of test F4.2
;
; Test F4.3 MTP* and cc for mem dst ++++++++++++++++++++++++++++++++++
;
tf0403: mov #100$,r1 ; dst for (r1)
mov #cp.psw,r4
clr (r4)
;
clr -(sp) ; zero value
ccc
mtpi (r1)
hcmpeq #cp0z00,(r4) ; check N=0,Z=1
;
push #1. ; positive value
ccc
<sen!sez> ; NZ=1
mtpi (r1)
hcmpeq #cp0000,(r4) ; check N=0,Z=0
;
push #-1. ; positive value
ccc
mtpi (r1)
hcmpeq #cpn000,(r4) ; check N=1,Z=0
;
push #1. ; positive value
sec ; C=1
mtpi (r1)
hcmpeq #cp000c,(r4) ; check C=1 kept
;
push #1. ; positive value
scc ; NZVC=1
mtpi (r1)
hcmpeq #cp000c,(r4) ; check C kept, NZV cleared
br 9999$
;
100$: .word 0 ; dst target
;
9999$: iot ; end of test F4.3
;
; Test F4.4 MFP* with all address modes ++++++++++++++++++++++++++++++
; Tests mode 0-7, and the special cases sp, (sp), (sp)+, @(sp)+, n(sp)
;
tf0404: clr cp.psw
mov #321,r0 ; current test value
mov #100$,r1 ; dst for (r1),(r1)+,-(r1),0(r1)
mov #200$,r2 ; dst for @(r2)+,@-(r2),@0(r2)
mov r1,r3 ; ptr to dst
;
mov r0,r5
mfpi r5 ; mode 0 - general purpose register
hcmpeq r0,(sp)+ ; check
;
inc r0
mov r0,(r3)
mfpi (r1) ; mode 1
hcmpeq r0,(sp)+ ; check
;
inc r0
mov r0,(r3)
mfpi (r1)+ ; mode 2
hcmpeq #100$+2,r1 ; check r1
hcmpeq r0,(sp)+ ; check
;
inc r0
mov r0,(r3)
mfpi -(r1) ; mode 4
hcmpeq #100$,r1 ; check r1
hcmpeq r0,(sp)+ ; check
;
inc r0
mov r0,(r3)
mfpi 0(r1) ; mode 6
hcmpeq r0,(sp)+ ; check
;
inc r0
mov r0,(r3)
mfpi @(r2)+ ; mode 3
hcmpeq #200$+2,r2 ; check r2
hcmpeq r0,(sp)+ ; check
;
inc r0
mov r0,(r3)
mfpi @-(r2) ; mode 5
hcmpeq #200$,r2 ; check r2
hcmpeq r0,(sp)+ ; check
;
inc r0
mov r0,(r3)
mfpi @0(r2) ; mode 7
hcmpeq r0,(sp)+ ; check
;
hcmpeq #stack,sp ; check SP normal
;
; check SP special cases
;
mfpi sp ; mode 0: SP as source
hcmpeq #stack,(sp)+ ; check
;
inc r0
push r0
mfpi (sp) ; mode 1: (SP) as source
hcmpeq r0,(sp)+ ; check mfpi pushed value
hcmpeq r0,(sp)+ ; check data pushed value
hcmpeq #stack,sp ; check stack state
;
inc r0
push r0
mfpi (sp)+ ; mode 2: (SP)+ as source
hcmpeq r0,(sp)+ ; check mfpi pushed value
hcmpeq #stack,sp ; check stack state
;
inc r0
mov r0,(r3) ; write data
push r3 ; push address
mfpi @(sp)+ ; mode 3: @(SP)+ as source
hcmpeq r0,(sp)+ ; check mfpi pushed value
hcmpeq #stack,sp ; check stack state
;
inc r0
push r0
mfpi 0(sp) ; mode 6: n(SP) as source
hcmpeq r0,(sp)+ ; check mfpi pushed value
hcmpeq r0,(sp)+ ; check data pushed value
hcmpeq #stack,sp ; check stack state
;
br 9999$
;
100$: .word 0 ; dst target
200$: .word 100$ ; ptr to dst
;
9999$: iot ; end of test F4.4
;
; Test F4.5 MFP* and cc for reg dst ++++++++++++++++++++++++++++++++++
;
tf0405: mov #cp.psw,r4
clr (r4)
;
clr r5 ; zero value
ccc
mfpi r5
hcmpeq #cp0z00,(r4) ; check N=0,Z=1
tst (sp)+ ; pop value
;
inc r5 ; positive value
ccc
<sen!sez> ; NZ=1
mfpi r5
hcmpeq #cp0000,(r4) ; check N=0,Z=0
tst (sp)+ ; pop value
;
neg r5 ; negative value
ccc
mfpi r5
hcmpeq #cpn000,(r4) ; check N=1,Z=0
tst (sp)+ ; pop value
;
neg r5 ; positive value
sec ; C=1
mfpi r5
hcmpeq #cp000c,(r4) ; check C=1 kept
tst (sp)+ ; pop value
;
scc ; NZVC=1
mfpi r5
hcmpeq #cp000c,(r4) ; check C kept, NZV cleared
tst (sp)+ ; pop value
;
9999$: iot ; end of test F4.5
;
; Test F4.6 MFP* and cc for mem dst ++++++++++++++++++++++++++++++++++
;
tf0406: mov #100$,r1 ; dst for (r1)
mov #cp.psw,r4
clr (r4)
;
clr (r1) ; zero value
ccc
mfpi (r1)
hcmpeq #cp0z00,(r4) ; check N=0,Z=1
tst (sp)+ ; pop value
;
inc (r1) ; positive value
ccc
<sen!sez> ; NZ=1
mfpi (r1)
hcmpeq #cp0000,(r4) ; check N=0,Z=0
tst (sp)+ ; pop value
;
neg (r1) ; negative value
ccc
mfpi (r1)
hcmpeq #cpn000,(r4) ; check N=1,Z=0
tst (sp)+ ; pop value
;
neg (r1) ; positive value
sec ; C=1
mfpi (r1)
hcmpeq #cp000c,(r4) ; check C=1 kept
tst (sp)+ ; pop value
;
scc ; NZVC=1
mfpi (r1)
hcmpeq #cp000c,(r4) ; check C kept, NZV cleared
tst (sp)+ ; pop value
br 9999$
;
100$: .word 0 ; dst target
;
9999$: iot ; end of test F4.6
;
; END OF ALL TESTS - loop closure ============================================
;
mov tstno,r0 ; hack, for easy monitoring ...
hcmpeq tstno,#54. ; all tests done ?
hcmpeq tstno,#60. ; all tests done ?
;
jmp loop
;

View File

@@ -1,10 +1,10 @@
; $Id: cpu_details.mac 1340 2023-01-01 08:43:05Z mueller $
; $Id: cpu_details.mac 1342 2023-01-02 15:18:19Z mueller $
; SPDX-License-Identifier: GPL-3.0-or-later
; Copyright 2022- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
; Copyright 2022-2023 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
;
; Revision History:
; Date Rev Version Comment
; 2022-12-25 1337 1.0 Initial version
; 2023-01-02 1342 1.0 Initial version
; 2022-07-18 1259 0.1 First draft
;
; Test CPU details
@@ -1542,12 +1542,14 @@ ta0404: mov #vhtbpt,v..bpt ; BPT handler
; B2 pipeline torture tests
; B2.1 self-modifying code, use (pc), -(pc)
; B2.2 self-modifying code, use (pc) case 2
; B3 specifier flow tests
; B3 specifier flow and abort tests
; B3.1 dstw flow and cc
; part 1: check cc for MOV for all modes
; part 2: check cc for CLR for all modes
; part 3: check cc for SXT for all modes
; part 4: check cc for MOV after abort for all modes
; B3.2 mtp and cc after abort
; B3.3 mfp and cc after abort
;
; Test B1: address mode torture tests +++++++++++++++++++++++++++++++++++++++
; This sub-section tests peculiar address node usage
@@ -1703,7 +1705,7 @@ tb0202: mov #2,r5
;
9999$: iot ; end of test B2.2
;
; Test B3: specifier flow tests +++++++++++++++++++++++++++++++++++++++++++++
; Test B3: specifier flow and abort tests +++++++++++++++++++++++++++++++++++
; This sub-section tests flow and cc properties
;
; Test B3.1 -- dstw flow and cc ++++++++++++++++++++++++++++++++++++++
@@ -1824,7 +1826,7 @@ tb0301: mov #123,r0 ; src for MOV
br 4200$
;
4100$: inc r5 ; bump counter
hcmpeq #cpnzvc,2(sp) ; PS cc untouched !!
hcmpeq #cpnzvc,2(sp) ; check PS cc untouched
rti ; continue (possible here!)
;
4200$: hcmpeq #7.,r5 ; check that all 7 mov get address error
@@ -1832,6 +1834,50 @@ tb0301: mov #123,r0 ; src for MOV
;
9999$: iot ; end of test B3.1
;
; Test B3.2 -- mtp and cc after abort ++++++++++++++++++++++++++++++++
; Verifies that cc is unchanged if last write fails.
; MTP* uses the dsta flow, it is sufficient to test only mode 1 and
; an odd address abort.
;
tb0302: cmpb systyp,#sy.sih ; skip on SimH
beq 9999$
;
mov #1,r1 ; use odd address
mov #1000$,v..iit ; set up iit handler
clr -(sp) ; push value
scc
mtpi (r1) ; will fail
halt
;
1000$: hcmpeq #cpnzvc,2(sp) ; check PS cc untouched
mov #stack,sp ; restore
mov #v..iit+2,v..iit ; restore
;
9999$: iot ; end of test B3.2
;
; Test B3.3 -- mfp and cc after abort ++++++++++++++++++++++++++++++++
; Verifies that cc is unchanged if last write fails.
; The last write in MFP* is a stack push, the test uses an odd address abort.
;
tb0303: cmpb systyp,#sy.sih ; skip on SimH
beq 9999$
;
inc sp ; set up odd stack
mov #100$,r1 ; set up read address (a valid one)
mov #1000$,v..iit ; set up iit handler
scc
mfpi (r1) ; will fail
halt
;
100$: .word 123
;
1000$: hcmpeq #cpnzvc,2(sp) ; check PS cc untouched
htsteq sp ; check that fatal stack error seen
mov #stack,sp ; restore
mov #v..iit+2,v..iit ; restore
;
9999$: iot ; end of test B3.3
;
; Section C: 11/70 specifics =================================================
; C1 Implementation differences
; C1.1 Register used as source and changed in dst flow
@@ -1890,7 +1936,7 @@ tc0103: mov #vhugen,v..iit ; set iit handler
; END OF ALL TESTS - loop closure ============================================
;
mov tstno,r0 ; hack, for easy monitoring ...
hcmpeq tstno,#30. ; all tests done ?
hcmpeq tstno,#32. ; all tests done ?
;
jmp loop
;