
/  DDT DRIVER (DR1025)

/ DDT - PDP8-DISC SYSTEM
/
/ DDT USES CORE FROM LOC THRU LOC+377 (2 PAGES)
/
/   INITIALLY IT ALSO USES 172-177,LOC-1200 THRU LOC+377
/   TO PREPARE THE DRIVER FOR USE.
/
/ DDT OVERLAYS CORE FROM 200-4577 AND
/ USES CELLS 3,4,5.  THE DRIVER MAY BE ANYWHERE ABOVE
/ 5777 AND IS SET BY SELECTING A VALUE FOR "LOC".

/THIS IS THE METHOD:
/
/1) LOAD DDT  PROPER AS FOLLOWS:
/ .LOAD
/ :IN-R:
/ ^
/ *OPT-1
/ *ST=7600
/ ^^
/  .SAVE DDT:200-4577;0
/
/2) SAVE A BLOCK OF CELLS THE SAME LENGTH AS DDT PROPER AS:
/
/  .SAVE USER:200-4577;0
/
/3) LOAD IN DDT DRIVER AND START AT LOC-200 AS:
/
/ .LOAD
/ *R:
/ ^
/ *OPT-2
/ ST=<LOC-200>
/ ^^
/ *IN-S:DDT,S:USER
/ ^
/ ^
/ .
/
/4) SAVE DDT DRIVER AS A SYSTEM PROGRAM:
/
/ .SAVE DDT!<LOC>-<LOC+377>;<LOC>
/ .


/ ERRORS ARE SHOWN BY "DDT?"

/ THE FOLLOWING THINGS MAY CAUSE ERRORS:
/	1. USER FILE TOO LARGE
/	2. SYSTEM DEVICE READ ERROR
/	3. NO COMMAND DECODER

/ DRIVER FOR DISC DDT

LOC=7200	/START LOCATION OF RESIDENT DDT.
BRKCEL=3	/FIRST OF 3 CONTIGUOUS CELLS USED BY BREAK POINTS.

	*LOC
STARTD,	JMS COMMON	/START UP DDT.
BRK1,	JMS COMMON	/GET NUMBER OF BRK PT.
BRK2,	JMS COMMON
BRK3,	JMS COMMON
COMMON,	0		/USE THE ENTRY POINT TO COUNT.
	DCA SAC		/SAVE THE AC
	RAL
	DCA LINKX	/SAVE THE LINK
/ SUBROUTINE TO STORE VALUES IN 3,4,5 AND SAVE AND GET CORE.
	TAD BRK
	DCA BRKCEL
	IAC
	TAD BRK
	DCA BRKCEL+1
	STL RTL
	TAD BRK
	DCA BRKCEL+2
	JMS I REPLAQ	/SAVE USER CONTENTS OF B.P. + SET WRITE ENABLE
	TAD ONE23
	TAD COMMON	/DETERMINE NUMBER OF BREAK POINT.
	DCA COMMON	/SAVE BREAK POINT NUMBER.
	TAD COMMON
	SNA
	JMP DDTIN


/ START BREAK POINT LOGIC
	TAD POINTQ
	JMS I SETUPV	/SETUP INST,TIMES
	TAD I TEMP	/POINT1,2,3
	IAC		/RETURN .+1
	DCA RETURN
CLLCLA,	CLL CLA
	TAD INST
	TAD A2000	/2000
	AND A200	/200
	SNA SZL CLA
	JMP OPIOZE	/OPR, IOT, OR PAGE ZERO REFERENCE
	TAD INST
	AND A200	/GET ABSOLUTE ADDRESS FOR MEM, REF. INST.
	SNA CLA		/THIS PAGE OR PAGE ZERO?
	JMP .+3		/PAGE 0
	TAD I TEMP	/GET CONTENTS OF POINT1,2,3
	AND A7600
	DCA TEMP	/GET PAGE BITS.
	TAD INST
	AND A177	/POSITION ON PAGE
	TAD TEMP	/+ PAGE
	DCA EFFADD	/ABSOLUTE ADDRESS OF MEMORY REFERENCE INSTRUCTION
	TAD INST
	AND A400	/400
	SNA CLA
	JMP .+3
	TAD I EFFADD	/INDIRECT REFERENCE--GET EFFECTIVE ADD.
	DCA EFFADD
	TAD INST
	AND NOPX	/7000
	TAD M4000	/-4000
	SZA CLA
	JMP OPIOZE-4
	TAD RETURN	/INST IS JMS--INDEX RETURN AND REPLACE BY JUMP
	DCA I EFFADD
	IAC
	TAD EFFADD
	DCA EFFADD
	TAD ANDI	/AND I EFFADD
	TAD A5000	/5000=JUMP
	JMP OPIOZE+1
	TAD INST
	AND NOPX	/7000
	TAD ANDI	/AND I EFFADD
	SKP

/HANDLES OPERATES, IOTS, AND PAGE ZERO MEMORY REFERENCE INSTRCUTIONS
OPIOZE,	TAD INST
	DCA EXINST	/EXECUTABLE INSTRCUTION
	ISZ I TIMES
	JMP ITER
DDTIN,	TAD SASCR	/START BLOCK OF SCRATCH AREA
	JMS I SAVEQ	/SAVE USER CORE
	TAD SADDT
	JMS I SAVEQ	/GET DDT
	TAD COMMON	/B.P. NUMBER


	JMS I DDTBZ	/JMS TO DDT PROPER.
SAC,	0
LINKX,	0
POINTQ,	POINT1-1
	TAB-1		/LIST OF USER CORE BLOCKS
SADDT,	26		/ADDRESS (DISC) OF DDT
	JMP GO


GO2,	TAD SASCR
	JMS I SAVEQ
ITER,	JMS I TODDTQ
	TAD LINKX
	RAR CLL
A7600,	7600	/CLA
	TAD SAC	/RESTORE LINK AND AC
EXINST,	HLT
	JMP I RETURN
	ISZ RETURN
	JMP .-2
GO,	DCA RETURN	/STORE START ADDRESS
	TAD CLLCLA	/CLEAR AC AND LINK
	DCA EXINST
	TAD RETURN	/FIND OUT IF RETURN IS TO 7600
	TAD A200	/IE., ^C OR 7600[G
	SZA CLA		/LEAVE B.P. CLEARED TO USER INSTRUCTIONS IF ^C
	JMP GO2
	TAD SASCR	/RESTORE USER CORE
	JMS I SAVEQ
	JMP ITER+1	/CONTINUE TO USER PROGRAM
DDTBZ,	DDTB		/ENTRY TO DDT
SYS=7642
ONE23,	-BRK1
EFFADD,	0
A5000,	5000
ANDI,	AND I EFFADD
M4000,	-4000
A177,	177
NOPX,	NOP
A400,	400
A2000,	2000
TODDTQ,	TODDT
SETUPV,	SETUPA
REPLAQ,	REPLAC
SASCR,	53		/START ADDRESS (DISC) OF SCRATCH.
BRK,	BRK1
SAVEQ,	SAVE
INST,	0
TIMES,	0
A200,	200
DDTB=2200
RETURN,	0
TEMP,	0	/USED AS POINTER TO CLEARED BP'S IN DDT
POINT1,	0
POINT2,	0
POINT3,	0
INST1,	0
INST2,	0
INST3,	0
ITER1,	0
ITER2,	0
ITER3,	0


READS,	0		/TEMP STORAGE


/ SAVE THE CORE IMAGE DESIRED

SAVE,	0
	DCA BLOCK
	TAD STADDR	/START ADDRESS OF SAVED
/			AREA IN CORE.
	DCA CORE
	TAD TABXX	/TAB POINTER TO LIST OF BLOCKS.
	DCA READS
SAVE1,	TAD I READS	/SETUP LINK FOR READS/WRITES
	DCA LINK	/IT IS ONLY IMPORTANT ON WRITE
	ISZ READS	/BUT DO IT ALWAYS TO SAVE CORE.
	JMS I SYSIO	/READ OR WRITE SYSTEM DEV.
FUNC,	0
BLOCK,	0
CORE,	0
LINK,	0
	JMP BAD		/ERROR IN READ.
	TAD LINK	/UPDATE LINK
	SNA
	JMP SAVE2
	DCA BLOCK
	TAD CORE
	TAD A200A
	DCA CORE
	JMP SAVE1
SAVE2,	TAD READX	/FORCE READ UNTIL DRIVER IS RE-ENTERED AT COMMON.
	DCA FUNC
	JMP I SAVE



/SUBROUTINE TO RESTORE USER CORE IMAGES AT BREAK POINTS.
REPLAC,	0
	JMS SETUPB
REPLA2,	TAD I T11	/PICKUP CONTENTS OF CELL POINTED TO BY POINT.
	DCA T44		/STORE IT.
	TAD I T22	/GET INSTRUCTION (INST1,2,3)
	DCA I T44	/RESTORE IT (DOUBLE INDIRECT) TO USER CORE.
	JMS ISZZ	/DONE YET?
	JMP REPLA2	/NO
	TAD WRITX	/YES, FORCE WRITE 
	DCA FUNC	/TO SAVE USER CORE IMAGE.
	JMP I REPLAC
/SUBROUTINE TO SETUP POINTERS AND COUNTER FOR BP SWAPPING.
SETUPB,	0
	TAD POINTX	/ADDRESS OF POINT1-1(DRIVER)
	IAC
	DCA T11		/ADDRESS OF START OF INSTRUCTION & POINTER LIST.
	TAD LENGTH
	TAD T11		/ADDRESS OF INST1,2,3(DRIVER)
	DCA T22
	TAD LENGTH
	CIA
	DCA T33		/-LENGTH
	JMP I SETUPB

/SUBROUTINE TO INCREVENT POINTERS FOR INSTALLATION AND REMOVAL
/OF BP UPON ENTRY TO AND EXIT FROM DDT.
ISZZ,	0
	ISZ T22		/INCREMENT "INST" POINTER
	ISZ T11		/INCREMENT "POINT" POINTER
	ISZ T33		/DONE?
	SKP		/NO
	ISZ ISZZ	/YES
	JMP I ISZZ

/SUBROUTINE TO SAVE INSTRUCTIONS AND INSERT JMP I 3,4,5
/ AT PROPER POINTS IN USER CORE.
TODDT,	0
TODDT2,	DCA T55		/INCREMENT FOR JMP I 3,4,5 (START AT 0)
	JMS SETUPB	/SETUP POINTERS TO USER BP AND INSTRUCTIONS.
TODDT3,	TAD I T11
	DCA T44		/PERFORM DOUBLE INDIRECT TO USER CORE.
	TAD I T44	/GET USER INSTRUCTION IN CORE
	DCA I T22	/SAVE IT IN "INST" TABLE
	TAD JMPI35
	TAD T55		/GET JMP I 3,4,5
	DCA I T44	/PUT IT IN USER CORE
	ISZ T55
	JMS ISZZ	/DONE YET?
	JMP TODDT3	/NO
	JMP I TODDT	/YES

/SUBROUTINE TO SETUP TIMES,INST
SETUPA,	0
	DCA I TEMPX	/SAVE POINTER TO POINT1,2,3
	TAD I TEMPX
	TAD LENGTH	/POINT1+<NUMBER OF BP>+3
	DCA READS
	TAD I READS
	DCA I INSTX
	TAD READS
	TAD LENGTH
	DCA I TIMEX
	JMP I SETUPA

READX,	3
WRITX,	5
STADDR,	200		/START ADDRESS IN CORE OF SAVED AREA.
BAD,	HLT
SYSIO,	SYS	/START OF SYSTEM I/O
JMPI35,	JMP I BRKCEL
TIMEX,	TIMES
INSTX,	INST
T11,	0
T22,	0
T44=SETUPB
T33,	0
T55,	0
A200A,	200
LENGTH,	3
POINTX,	POINT1-1
TEMPX,	TEMP
TABXX,	TAB+1	/FIRST
TAB,	0		/LIST OF USER BLOCKS 18 LONG.

/ ONCE ONLY CODE. DO NOT TRY TO RESTART.

	*LOC-200
	7600		/CLA
	DCA COUNT	/BLOCK COUNTER=0
	TAD .-2		/-200
	DCA FAIL	/TO CHECK FOR NO COMMAND DECODER.
	JMS I SYSX	/READ SAM BLOCK
	3
	200		/GET SAM BLOCK
ADD,	LOC-1000
	0
	JMP BAD2	/QUIT
LOOP,	CLA
	TAD I ADD
	ISZ ADD		/INCREMENT POINTER TO SAM BLOCK.
	AND A77
	TAD M5		/SAM NUMBER = 5
	SNA		/COMMAND DECODER?
	JMP OK		/YES
	ISZ COUNT	/NO, KICK BLOCK POINTER
	ISZ FAIL
	JMP LOOP
	JMP BAD2	/NO COMMAND DECODER


OK,	TAD LIST0	/"S:<.DDT>,S:<USER>"
	TLS
	TSF
	JMP .-1
	SNA CLA
	JMP ON		/QUIT WHEN LIST=0
	ISZ OK
	JMP OK
LIST0,	215
	212
	323		/S
	272		/:
	274		/<
	256		/.
	304		/D
	304		/D
	324		/T
	276		/>
	254		/,
	323		/S
	272		/:
	274		/<
	325		/U
	323		/S
	305		/E
	322		/R
	276		/>
	215
	212
	0
ON,	TAD COUNT	/COLLECT STARTING BLOCK NUMBER OF CD.
	DCA LINKF
	TAD LINKF
	DCA .+3
	JMS I SYSX
	1003
	0
	LOC-1000
	0
	LOC-1000
/    RETURN FROM COMMAND DECODER HERE........

CONT,	TAD INITDD+1	/GET BLOCK 1 OF DDT
	DCA I DDTBL
	TAD INITDD+3	/GET BLOCK 1 OF USER CORE IMAGE FILE
	DCA I SCRBL
	TAD I SCRBL
	DCA I TABX	/STORE FIRST BLOCK NUMBER IN TAB
	ISZ TABX
	TAD I SCRBL
	DCA .+3
LOOP2,	JMS I SYSX
	3
BLOCKQ,	0
	LOC-1000
LINKQ,	0
	JMP BAD2
	TAD LINKQ	/COLLECT LIST OF BLOCKS USED BY USER CORE IMAGE FILE
	SNA		/END OF FILE?
	JMP LAST	/YES
	DCA I TABX	/NO
	TAD I TABX
	ISZ TABX
	DCA BLOCKQ
	TAD TABX	/THE LOSING USER TRIED TO USE A
	AND A77		/LARGE FILE, DIE.
	SZA CLA
	JMP LOOP2

BAD2,	TAD LIST
	TLS
	TSF
	JMP .-1
	SNA
	JMP I .+1
MONRET,	7600
	ISZ BAD2
	JMP BAD2
LIST,	215	/<CR>
	212	/<LF>
	304	/D
	304	/D
	324	/T
	277	/?
	215	/<CR>
	212	/<LF>
	0
LAST,	DCA I TABX	/ZERO THE LAST ENTRY (LAST LINK)
	JMP I MONRET	/GO TO MONITOR, DRIVER IS INITIALIZED.

M5,	-5
A77,	77
SYSX,	SYS
FAIL,	-200
COUNT,	0
DDTBL,	SADDT
SCRBL,	SASCR
TABX,	TAB
INITDD,	0	/AREA USED BY COMMAND DECODER TO
	0	/STORE OUTPUT.

	*172
LINKF,	0
	0
INIT,	INITDD
	7403	/SAVE FILES, NO OPT, NO OUTPUT , 2 INPUT FILES = OPTIONS
	0
	CONT	/RETURN FROM CD
$
