Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-01 - 43,50212/dio.mac
There are no other files named dio.mac in the archive.
	TITLE DIO
;CENTRAL DISK I/O ROUTINE
;	CALL DIO(LR,IO,IR,NSPR)
;	LR- SECTOR NUMBER TO START I/O WITH
;	IO- INPUT=1,OUTPUT=2,EMPTY BUFFER AFTER LAST WRITE=2
;	IR- ARRAY IN MAIN PROGRAM WHERE DATA IS STORED
;	NSPR- NUMBER OF SECTORS TO READ OR WRITE
;THE ROUTINE WRITES 12 SECTORS PER BLOCK.
;THE BLOCK NUMBER AND MAXIMUM BLOCK NUMBER IN PACK(DEC FILE)
;IS STORED WITH THE DATA IN LAST TWO WORDS OF BLOCK.
;WORDS 121-126 ARE NOT USED.
;PACK MUST BE SET UP USING PROGRAM DPACK.
;A SUBROUTINE OPEN IS CALLED UPON FIRST ENTRY TO DO
;LOOKUP ,ENTER SEQUENCE ON APPROPIATE CHANNELS.
;CHANNELS ARE ASSIGNED FROM 17 DOWN TO AVOID(HOPEFULLY)
;FORTRAN ASSIGNMENTS.
;I/O IS ONLY DONE TO THE DISK WHEN SECTOR NUMBER IS OUTSIDE
;THE CURRENT BLOCK IN THE BUFFER.
;ALL I/O IS IN UPDATE - DUMP MODE.
	ENTRY DIO
	INTERN BUF, MAX, FLAG, NO.CHN
	EXTERN OPEN
	NO.PKS=4
	MASK=7
	BLOCK=10
	WORD=11
	LR=12
	IO=13
	ARRAY=14
	NS=15
	SEC=17
	D=4
	OPDEF TTCALL [51B8]
	DEFINE TTYOUT (ADR) <TTCALL 3, ADR>
	DEFINE SETCHN (ADR) <DPB D, [POINT 4, ADR, 12]>
ACSAVE:	BLOCK 17
DIO:	0
	MOVSI 1
	HRRI ACSAVE
	BLT ACSAVE+16
	MOVE LR, @(16)
	JUMPLE LR, LRERR
	MOVE IO, @1(16)
	MOVEI ARRAY, @2(16)
	MOVE NS, @3(16)
	CAIN IO,2
	JSR EMPTY
	CAIN IO,2
	JRST EXIT
	MOVE MASK, LR
	IDIV MASK, MIL
	MOVE MASK
	IMUL MIL
	SUB LR,
	MOVEI D, 17
	SUB D, MASK
	SETCHN INPUT+1
	SETCHN INPUT+2
	SETCHN INPUT+3
	SETCHN OUTPUT+1
	SETCHN OUTPUT+2
	SETCHN OUTPUT+3
	JUMPLE NS, NSERR
	MOVE SEC, LR
	ADDI LR, -1(NS)
	MOVEI NO.PKS
	MOVEM MAX
	SKIPN FLAG
	JSA 16, OPEN
	MOVE MASK
	CAML NO.CHN
	JRST MSKERR
	IMULI 200
	ADDI BUF-1
	HRRM LIST
	AOJ
	MOVEM BUFPNT#
	ADDI 176
	MOVEM LB#
	AOJ
	MOVEM SIZE#
	SETOM FIRST#
LOOP:	CAMLE SEC, @SIZE
	JRST OVFL
	JSR ALG
	CAIE IO, 1
	JRST OUT
	SKIPN FIRST
	JRST .+3
	SKIPN ROW(MASK)
	JSR EMPTY
	CAME BLOCK, @LB
	JSR INPUT
	ADD WORD, BUFPNT
	MOVS 1, WORD
	HRR 1, ARRAY
	BLT 1, 11(ARRAY)
	JRST NEXT
OUT:	CAMN BLOCK, @LB
	JRST .+5
	SKIPE FIRST
	SKIPN ROW(MASK)
	JSR EMPTY
	JSR INPUT
	MOVS 1, ARRAY
	ADD WORD, BUFPNT
	HRR 1, WORD
	BLT 1, 11(WORD)
NEXT:	CAML SEC, LR
	JRST .+5
	AOJ SEC,
	ADDI ARRAY, 12
	CLEARM FIRST
	JRST LOOP
	MOVEM IO,ROW(MASK)
EXIT:	MOVSI ACSAVE
	HRRI 1
	BLT 17
	JRA 16, 4(16)
INPUT:	0
	USETI (BLOCK)
	INPUT LIST
	STATO 740000
	JRST @INPUT
	TTYOUT CRLF
	TTYOUT TE
	TTYOUT [ASCIZ"INPUT."]
	CALLI 12
OUTPUT:	0
	USETO (BLOCK)
	OUTPUT LIST
	STATO 740000
	JRST @OUTPUT
	TTYOUT CRLF
	TTYOUT TE
	TTYOUT [ASCIZ"OUTPUT."]
	CALLI 12
ALG:	0
	MOVE 6, SEC
	SOJ 6, 
	MOVEM 7,SAVE#
	IDIVI 6, 14
	MOVE 7,SAVE    ;RESTORE AC(7) AFTER INTEGER DIVIDE
	MOVE BLOCK, 6
	AOJ BLOCK,
	IMULI 6, 14
	MOVE WORD, SEC
	SOJ WORD,
	SUB WORD, 6
	IMULI WORD, 12
	JRST @ALG
LRERR:	TTYOUT CRLF
	TTYOUT [ASCIZ"SECTOR NUMBER IS NOT POSITIVE."]
	CALLI 12
MSKERR:	TTYOUT CRLF
	TTYOUT [ASCIZ"FILE NOT ON ANY PACK."]
	CALLI 12
NSERR:	TTYOUT CRLF
	TTYOUT [ASCIZ"NO. SECTORS NOT POSITIVE."]
	CALLI 12
OVFL:	TTYOUT CRLF
	TTYOUT [ASCIZ"SECTOR EXCEEDS PACK SIZE."]
	CALLI 12
EMPTY:	0
	MOVE BLOCK
	MOVE BLOCK, @LB
	JSR OUTPUT
	MOVEM BLOCK
	JRST @EMPTY
CRLF:	BYTE (7) 015, 012
MIL:	^D1000000
ROW:	REPEAT NO.PKS, <1>
BUF:	BLOCK NO.PKS*200
MAX:	0
FLAG:	0
NO.CHN:	0
LIST:	IOWD 200,
	0
TE:	ASCIZ"TRANSMISSION ERROR ON "
	END