:: pdp9_test.ini
::
:: Run the paper tape-based diagnostics for the PDP-9 simulator.
::
:: Maximum memory, Extended Arithmetic Element
set cpu 32k
set cpu eae

cd %~p0
:: Limit maximum diagnostic execution time
::
set runlimit 40M instructions
set on
on error ignore
on runtime echof "\r\n*** Test Runtime Limit %SIM_RUNLIMIT% %SIM_RUNLIMIT_UNITS% Exceeded ***\n"; exit 1

:: LAC, TAD, ADD, SAD, XOR and all Operate instruction test (D01A)
echof -n "\rRunning MAINDEC-9A-D01A PDP-9 Instruction Test 1"
if not exist diags/maindec-9a-d01a-ph.rim echof "\r\nMISSING - Diagnostic '%~p0diag/maindec-9a-d01a-ph.rim' is missing\n"; exit 1
att -q ptr diags/maindec-9a-d01a-ph.rim
:: Break at 13030 to stop execution after a full pass is done.
de all 0
nobreak all
break 13030
de asw 22
boot -q ptr
go -q 13041
if (PC != 013030 || AC != 000000) echof "Failed."; ex pc; ex ac; exit 1
echof Passed"

:: DZM, DAC, ISZ, JMP, CAL, JMS, XCT, Autoindex, Indirect, Time Clock, PI, DBR (D02A)
echof -n "Running MAINDEC-9A-D02A PDP-9 Instruction Test 2"
if not exist diags/maindec-9a-d02a-ph.rim echof "\r\nMISSING - Diagnostic '%~p0diag/maindec-9a-d02a-ph.rim' is missing\n"; exit 1
att -q ptr diags/maindec-9a-d02a-ph.rim
:: Break at 6256 to stop execution after a full pass is done.
de all 0
nobreak all
break 6256
de asw 22
boot -q ptr
go -q 6265
if (PC != 006256 || AC != 000000) echof "Failed."; ex pc; ex ac; exit 1
echof "Passed"

:: JMP Self (D0DB)
echof -n "Running MAINDEC-9A-D0DB PDP-9 JMP-Self Test"
if not exist diags/maindec-9a-d0db-ph.rim echof "\r\nMISSING - Diagnostic '%~p0diag/maindec-9a-d0db-ph.rim' is missing\n"; exit 1
att -q ptr  diags/maindec-9a-d0db-ph.rim
:: Break at 17521 to stop execution after a full pass is done.
de all 0
nobreak all
break 17521
de asw 17500
boot -q ptr
go -q 17500
if (PC != 017521 || AC != 000000) echof "Failed."; ex pc; ex ac; exit 1
echof "Passed"

:: JMP Self (D0EA)
echof -n "Running MAINDEC-9A-D0EA PDP-9 JMP Y - Interrupt Test"
if not exist diags/maindec-9a-d0ea-ph.rim echof "\r\nMISSING - Diagnostic '%~p0diag/maindec-9a-d0ea-ph.rim' is missing\n"; exit 1
att -q ptr diags/maindec-9a-d0ea-ph.rim
:: Break at 17474 to stop execution after a full pass is done.
de all 0
nobreak all
de asw 17400
boot -q ptr
break 17474
go -q 17400
if (PC != 017474) echof "Failed."; ex pc; ex ac; exit 1
echof "Passed"

:: JMP Self (D0FA)
echof -n "Running MAINDEC-9A-D0FA PDP-9 JMS Y - Interrupt Test"
if not exist diags/maindec-9a-d0fa-ph.rim echof "\r\nMISSING - Diagnostic '%~p0diag/maindec-9a-d0fa-ph.rim' is missing\n"; exit 1
att -q ptr diags/maindec-9a-d0fa-ph.rim
:: Break at 17512 to stop execution after a full pass is done.
de all 0
nobreak all
break 17512
de asw 17400
boot -q ptr
go -q 17400
if (PC != 017512) echof "Failed."; ex pc; ex ac; exit 1
echof "Passed"

:: JMP Self (D0BA)
echof -n "Running MAINDEC-9A-D0BA PDP-9 ISZ Test"
if not exist diags/maindec-9a-d0ba-ph.rim echof "\r\nMISSING - Diagnostic '%~p0diag/maindec-9a-d0ba-ph.rim' is missing\n"; exit 1
att -q ptr diags/maindec-9a-d0ba-ph.rim
:: Break at 144 to stop execution after a full pass is done.
de all 0
nobreak all
break 144
de asw 100
boot -q ptr
go -q 100
if (PC != 000144 || AC != 000000) echof "Failed."; ex pc; ex ac; exit 1
echof "Passed"

echof
echof "!! All Tests Passed !!"
echof
exit 0
