.; Assemble, load, and run RT-11 simulated program. Build file will be
.; created if it does not already exist. The simulator will be assembled
.; using prefix file RT11PRE.MAC if it exists. This may contain optional
.; definitions of:
.; CHANS=n		; No of I/O channels (default 9)
.; TERMS=n		; No of additional terminals (default 7)
	.ENABLE SUBSTITUTION
.; Assign list, task, and map devices to SY:, unless user-assigned elsewhere
	.TESTFILE LS:[0,0]INDEXF.SYS
	.IF <FILERR> <> 1 ASN SY:=LS:
	.TESTFILE MP:[0,0]INDEXF.SYS
	.IF <FILERR> <> 1 ASN SY:=MP:
	.TESTFILE TK:[0,0]INDEXF.SYS
	.IF <FILERR> <> 1 ASN SY:=TK:
	.SETS MCR ""
	.IF <CLI> <> "MCR" .SETS MCR "MCR "
	.SETS MACIT MCR+"MAC"
	.IF P1 = "" .ASKS P1 Test program name
	.SETS LIST ""
	.ASK YN List
	.IFT YN .SETS LIST ",LS:LP/NL:SYM:TOC"
	.IF P1 = "" .GOTO NOPROG
	.ASK YN Assemble 'P1'
	.IFT YN 'MACIT' 'P1''LIST'=SYSMAC.SML/ML,'P1'
	.IF <EXSTAT> <> 1 .EXIT
	.IFT YN PIP 'P1'.OBJ/PU
.NOPROG: .IF LIST <> "" .SETS LIST ",LS:RT11/-SP"
	.ASK YN Assemble RT11
	.SETS P2 ""
	.TESTFILE RT11PRE.MAC
	.IF <FILERR> = 1 .SETS P2 "RT11PRE,"
	.IFT YN .IF LIST <> "" PIP LS:RT11.LST;*/DE/NM
	.IFT YN 'MACIT' RT11'LIST'=LB:[1,1]EXEMC/ML,SY:'<UIC>''P2'RT11
	.IF <EXSTAT> <> 1 .EXIT
	.IFT YN PIP RT11.OBJ/PU
	.IF P1 = "" .EXIT
	PIP TK:'P1'.TSK;*/DE/NM,MP:'P1'.MAP;*
	.TESTFILE 'P1'BLD.CMD
	.IF <FILERR> = 1 .GOTO HAVBLD
	.SETS P2 P1[1:3]
	.OPEN 'P1'BLD.CMD
.ENABLE DATA
TK:'P1'/DA/FP,MP:'P1'/-SP='P1',RT11
/
LIBR=FCSRES:RO
EXTTSK=2000
TASK=...'P2'
ACTFIL=0
UNITS=18
ASG=SY:1:2:3:4:5:6:7:8
ASG=SY:9:10
ASG=TI:11
ASG=TT1:12,TT2:13
ASG=TT3:14,TT4:15,TT5:16,TT6:17,TT7:18
; Prevent ODT intercepting traps:
GBLPAT='P1':.ODTL1-26:0		; Odd address
GBLPAT='P1':.ODTL1-24:0		; Memory protect
GBLPAT='P1':.ODTL1-20:0		; IOT
GBLPAT='P1':.ODTL1-16:0		; Illegal instruction
GBLPAT='P1':.ODTL1-14:0		; Simulator RT-11 EMTs
GBLPAT='P1':.ODTL1-12:0		; TRAP
GBLPAT='P1':.ODTL1-10:0		; FIS exception
TSKV=VECTBL:8
//
.DISABLE DATA
.CLOSE
.HAVBLD: TKB @'P1'BLD
	'MCR'SET /HOLD=TI:
	PIP TI:=MP:'P1'.MAP
	'MCR'SET /NOHOLD=TI:
	.XQT RUN TK:'P1'
	.DISABLE DISPLAY
