Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-01 - 43,50207/alocsp.mac
There are no other files named alocsp.mac in the archive.
TITLE ALOCSP- GEN FILE ALLOCATION APR 28 71 V 006

VALCFL==006

LOC 137
OCT VALCFL

RELOC

;ACCUMULATORS

F=0		;FLAGS
A=1		;WORK REGISTERS
B=2
C=3
M=4		;MESSAGE ADDRESS AND TEMPORARY AC
WD=5
WD1=6
CH=7
SW=10
T=15
NBAL=16
P=17		;PUSH DOWN POINTER

;FLAGS

DOTF==1		;PERIOD SEEN IN COMMAND STRING
TYO==2
PARAL=4		;PARAL ALOLCATION  OK TO FRAGMENT SPACE

;ARGUMENT LIST

EXLLEN==26	;LENGTH OF ARGUMENT LIST FOR EXTENDED LOOKUP, ENTER

EXLPPN==1	;DIRECTORY NAME
EXLNAM==2	;FILE NAME
EXLEXT==3	;EXT
EXLALC==11	;BLOCKS ALLOCATED
EXLPOS==12	;POSITION ON PHYSICAL UNIT TO ALLOCATE NEW BLOCKS
EXLERR==3	;WORD CONTAINING ERROR CODE FOR ENTER ERRORS

TTY==0		;CHANNEL FOR TTY
STR==1		;CHANNEL FOR FILE
LPDL==24	;LENGTH OF PUSHDOWN LIST

IFNDEF PURESW,<PURESW==0>

;STORAGE MACROS

DEFINE U(A)<UU(A,1)>

.ZZ==140

IFN PURESW,<
	HISEG		;FOR THE LOADER
	DEFINE UU(A,B)<
	A==.ZZ
	.ZZ==.ZZ+B
>	;END MACRO DEFINITION OF UU
>	;END CONDITIONAL ON PURESW

IFE PURESW,<
	DEFINE UU(A,B)<
	A:	BLOCK	B
	.ZZ==.ZZ+B
>	;END MACRO DEFINITION OF UU
>	;END CONDITIONAL ON PURESW
ALCFIL:	JFCL
	CALLI	0		;RESET
	MOVE	P,PDP
	INIT	TTY,		;OPEN TELETYPE
	SIXBIT	.TTY.
	XWD	OBUF,IBUF
	  CALLI	12		;EXIT IF NO TTY
	MOVEI	M,[ASCIZ .
/H FOR HELP.]
	PUSHJ	P,MSG
FILAL1:	MOVEI	M,[ASCIZ .
FILE? .]
	SETZM SW
	PUSHJ	P,MSG
	PUSHJ	P,GETNAM	;READ FILE TO ALLOCATE SPACE FOR
ALC:	PUSHJ	P,INITT		;GO INIT
	JRST BADFIL 		;NO GOOD
	SETZM	NBAL
	LOOKUP	STR,LOOKBF		;IS THERE ALREADY A FILE?
	JRST	NOBLOK	; NO
	PUSHJ	P,CHALK		;GET NBAL ALC ALREADY
	MOVEI	M,[ASCIZ . BLOCKS ALREADY ALLOCATED
.]
	PUSHJ	P,MSG
NOBLOK:	MOVEI	M,[ASCIZ .ALLOCATE? .]
	PUSHJ	P,MSG
	PUSHJ	P,DECRD		;GET TOTAL NUMBER OF BLOCKS TO ALLOCATE
	MOVEM	WD,A		;SAVE ALLOCATION REQUESTED
	SETZ	B,		;CLEAR POSITION ON UNIT
	CAIGE	CH,40		;SKIP IF MORE INPUT COMING
	JRST	GOALC		;NO POSITION SPECIFIED
	CAIE	CH,","		;COMMA, MUST SEPARATE
	JRST	BADALC		;TOO BAD
	PUSHJ	P,DECRD		;GET POSITION TO ALLOCATE NEW BLOCKS
	CAIL	CH,40		;NOT SUPPOSED TO BE ANYTHING ELSE
	JRST	BADALC		;PITY
	MOVE	B,WD
GOALC:	PUSHJ	P,SETALC		;GO GET ALLOCATION
	TRNE	SW,PARAL		;ONLY PARATIAL IS IT OK?
	JRST	TRYAG		;YES DOESN'T CARE WHRERE SPACE IS
	MOVE	M,ERRLST+17
	PUSHJ	P,MSG
	PUSHJ	P,WRAL
	MOVEI	M,[ASCIZ . BLOCKS ONLY   IS FRAGMENTED SPACE OKAY?.]
	PUSHJ	P,MSG
	PUSHJ P,YESNO	;ASK FOR ANSWER
	JRST	NOALC1 	; NO STOP
TRYAG:	SETZ	B,
	PUSHJ	P,CHALKK	; SET UP TO TRY AGAIN
	PUSHJ	P,SETALC	;DO ANOTHER ALLOCATIOM
	JRST	TRYAG		;TRY AGIN IF YOU DIDN'T GET ALL
				;DONT RETUNR  HERE IF GOT ALL
INITT:	MOVEI	A,17		;USE DUMP MODE SO CLOSE DONT DUMP  BUFFERS
	SETZ	C,
	SKIPN	B,STRNAM
	MOVSI	B,(SIXBIT .DSK.) ;DSK IS DEFAULT CASE
	OPEN	STR,A		;OPEN STR
	POPJ	P,
	MOVEI	WD,EXLLEN-1	;LENGTH OF ARGUMENT LIST FOR EXTENDED LOOKUP
	MOVEM	WD,LOOKBF
	MOVE	WD,FILE
	MOVEM	WD,LOOKBF+EXLNAM
	HLLZ	WD,EXT
	MOVEM	WD,LOOKBF+EXLEXT
	MOVE	WD,PPN
	MOVEM	WD,LOOKBF+EXLPPN
	AOS	(P)
	POPJ	P,
SETALC:	CAMG	A,LOOKBF+EXLALC ;SKIP IF HE WANTS MORE BLOCKS
	SETZ	B,		;NO NEW BLOCKS - MAKE SURE POS=0
	SETZ	WD,
	MOVEM	B,LOOKBF+EXLPOS
	HLLZS	LOOKBF+EXLERR
	MOVEM	A,LOOKBF+EXLALC	;STORE NEW ALLOCATION
	ENTER	STR,LOOKBF	;NEW ALLOCATION
	  JRST	NOALC		;DIDN'T MAKE IT
	MOVEI	M,[ASCIZ .
ALLOCATED.]			;OK
	JRST	DBLK
NOALC:	HRRZ	WD,LOOKBF+EXLERR ;GET ERROR CODE
	CAIN	WD,17	;PARTIAL ALLOCATION ERROR?
	POPJ	P, ; YES RETURN TO CALLER
	MOVE	M,ERRLST(WD)	;GET ADDRESS OF ERROR MESSAGE
	JRST	CPOPR	; TYPE ERROER MESSAGE AND STOP
DBLK:	CAMLE	A,LOOKBF+EXLALC	;DID WE GET THEM ALL ?
	POPJ	P,	; MAY TRY AGAIN
	JRST	CPOPR	; OK DONE
WRAL:	CLOSE	STR,4
CHALK:	MOVE	WD,LOOKBF+EXLALC	; GET ALLOCATION
	MOVEI	M,[ASCIZ/
/]
	PUSHJ	P,MSG
	MOVE	T,A	;PREVENT CLOBBERING OF REQUESTED ALLOC
	PUSHJ	P,DECPNT
	MOVE A,T
	POPJ	P,
CHALKK:	CLOSE	STR,4
	CAML	NBAL,LOOKBF+EXLALC	;DID WE GET MORE?
	JRST	NOMORE	;CANT GET MORE FILL DSK OR RIB ETC
	LOOKUP STR,LOOKBF	;LOOKUP FOR UPDATING ALLOCATION
	JRST	LOOKER	;SOMETHIGS REALLY WRONG
	MOVE	NBAL,LOOKBF+EXLALC
	POPJ	P,
LOOKER:	MOVEI	M,[ASCIZ .FILE NOT THERE SHOULD BE
.]
	JRST	CPOPR
NOMORE:	PUSHJ	P,CHALK
	MOVEI	M,[ASCIZ . BLOCKS ONLY CANT GET MORE
.]
	JRST	CPOPR
YESNO:	PUSHJ	P,GETONE
	CAIN CH,"Y"
	AOS	(P)
	POPJ	P,
GETNAM:	SETZM	STRNAM
	SETZM	FILE
	SETZM	EXT
	SETZM	PPN
	SETZM	LOOKBF+EXLALC
	TRZ	F,DOTF
NAM0:	PUSHJ	P,SIXAN
	CAIE	CH,":"
	JRST	NAM1
	MOVEM	WD,STRNAM
	JRST	NAM0
NAM1:	CAIE	CH,"."
	JRST	NAM2
	TRO	F,DOTF
	MOVEM	WD,FILE
	JRST	NAM0
NAM2:	CAIE	CH,"["
	JRST	NAM3
	TRNE	F,DOTF
	MOVEM	WD,EXT
	TRNN	F,DOTF
	MOVEM	WD,FILE
	PUSHJ	P,OCTRD
	CAIE	CH,","
	JRST	FILERR
	HRLZM	WD,PPN
	PUSHJ	P,OCTRD
	CAIE	CH,"]"
	JRST	FILERR
	HRRM	WD,PPN
	PUSHJ	P,TTI
	CAIGE	CH,40
	POPJ	P,
NAM3:	CAIE	CH,"/"
	JRST	NAM4
	TRNE	F,DOTF
	MOVEM	WD,EXT
	TRNN	F,DOTF
	MOVEM	WD,FILE
	PUSHJ	P,GETONE
	CAIN	CH,"X"
	CALLI	12
	CAIN	CH,"H"
	JRST	HELPMS
	CAIN	CH,"A"	;ALLOCATE
	POPJ	P,
	CAIN	CH,"P"	;PARTAILLY FRAGMENTED
	JRST	PREAL
	CAIN	CH,"D"
	JRST	DELETE	;DELETE FILE
	CAIN	CH,"C"
	JRST	CHECK	;SEE WHAT WE HAVE NOW
	CAIN	CH,"R"	;READ RIB
	JRST	READR
	JRST	FILERR
NAM4:	CAIL	CH,40
	JRST	FILERR
	TRNE	F,DOTF
	MOVEM	WD,EXT
	TRNN	F,DOTF
	MOVEM	WD,FILE
	POPJ	P,
PREAL:	TRO	SW,PARAL
	POPJ	P,
CHECK:	PUSHJ	P,INITT
	JRST	BADFLL
	LOOKUP	STR,LOOKBF
	JRST	LOOKER
	PUSHJ	P,CHALK
	MOVEI	M,[ASCIZ . BLOCKS CURRENTLY ALLOCATED
.]
	JRST	CPOPR
DELETE:	PUSHJ	P,INITT
	JRST	BADFLL
	LOOKUP	STR,LOOKBF
	JRST	LOOKER
	SETZM	LOOKBF+EXLNAM	;READY TO DELTE
	RENAME	STR,LOOKBF+EXLNAM	;DELETE
	JRST	NOGOOD
	MOVEI	M,[ASCIZ . FILE DELETED
.]
	JRST	CPOPR
NOGOOD:	MOVEI	M,[ASCIZ . CANNOT DELTE FILE
.]
	JRST	CPOPR
READR:	PUSHJ	P,INITT
	JRST	BADFLL
	LOOKUP	STR,LOOKBF
	JRST	LOOKER
	USETI	STR,0	;SET UP TO READ IN THE RIB
	INPUT	STR,INLST
	GETSTS	STR,T
	TRNE	T,740000
	JRST	RDERR
	MOVSI	C,-200	;SET TO DUMP THE RIB
LINE:	MOVEI	M,[ASCIZ .
.]
	PUSHJ	P,MSG
	MOVSI	B,-5	;OUTPT 5 PER LINE
NWD:	PUSHJ	P,BLANK ;FILL BLANKS BETWEEN
WRD:	MOVE	WD,RIBUF(C)	;GET WORD OF RIB
	PUSHJ	P,DMPPNT	;PRINT IT
	AOBJN	C,LNTST
	MOVEI	M,[ASCIZ .
.]
	JRST	CPOPR	;ALL DONE
LNTST:	AOBJN	B,NWD
	JRST	LINE
BLANK:	MOVEI	M,[ASCIZ .  .]
	PUSHJ	P,MSG
	POPJ	P,
RDERR:	MOVEI	M,[ASCIZ/CANNOT READ RIB
/]
	JRST	CPOPR
INLST:	IOWD	200,RIBUF
	Z
RIBUF:	BLOCK	200
FILERR:	MOVEI	M,[ASCIZ .?BAD FILE NAME SYNTAX.]
	JRST	CPOPR

HELPMS:	MOVEI	M,HLPM
	JRST	CPOPR
HLPM:	ASCIZ \
ALCFIL IS A PROGRAM WHICH ALLOCATES SPACE ON A FILE STRUCTURE FOR A FILE
IT FIRST ASKS  FILE?
THE RESPONSE SHOULD BE  STR:FILE.EXT[PROJ,PROG]/SW

 IF STR IS OMITTED,DSK IS ASSUMED, 0 ASSUMED OTHERWISE
WHERE SW IS:

/A	FOR ALLOCATION- CONTIGUOUS DSK SPACE ONLY
	IT THEN ASKS  ALLOCATE?

	THE RESPONSE SHOULD BE  N OR N,M (BOTH DECIMAL NUMBERS)
	 N IS THE TOTAL NUMBER OF BLOCKS TO BE ALLOCATED FOR THE FILE
	 M IF SPECIFIED IS THE POSITION ON THE PHYSICAL UNIT WHERE
	  NEW BLOCKS ARE TO BE ALLOCATED.  THIS ARGUMENT IS NOT NECESSARY.

/P	FOR ALLOCATION NON-CONTIGUOUS SPACE OKAY. IE. KEEP DOING
	 EXTENDED ENTERS UNTIL TOTAL SPACE OBTAINED

/C	TO MERELY CHECK PRESENT ALLOCATION

/D	TO DELETE A FILE

/R 	TO READ AND DUMP THE RIB.


/H TYPES THIS TEXT

/X EXITS TO MONITOR

IF NO SWITCH GIVEN THE /A IS ASSUMED
\

BADFLL:	POP	P,
BADFIL:	MOVE	M,[ASCIZ .?CANT OPEN STR
.]
	JRST	NOALC1

BADALC:	MOVEI	M,[ASCIZ .?ILLEGAL SPECIFICATION.]
	SKIPA
CPOPR:	POP	P,
NOALC1:	CLOSE	STR,4		;KEEP NEW ALLOCATION
NOALC2:	RELEASE	STR,
	PUSHJ	P,MSG
	OUTPUT	TTY,
	JRST	FILAL1
SIXAN:	SETZ	WD,
	MOVE	M,[POINT 6,WD]
	PUSHJ	P,SSP
	JRST	.+2
SIXANL:	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AIG	CH,"Z"
	CAIGE	CH,"0"
	JRST	TEST12
	MOVE	WD,CH
GETEND:	PUSHJ	P,TTI
	CAIE	CH,12
	JRST	GETEND
	MOVE	CH,WD
	POPJ	P,
DMPPNT:	MOVE	M,[POINT 3,WD]
	ILDB	CH,M
	PUSHJ	P,TTO-1
	TLNE	M,770000
	JRST	DMPPNT+1
	POPJ	P,
TEST12:	CAIN	CH,12
	POPJ	P,
	JRST	GETONE
ERRLST:	[ASCIZ /
FILE NOT FOUNT/]
	[ASCIZ /
INCORRECT PROJECT, PROGRAMMER NUMBER/]
	[ASCIZ /
PROTECTION FAILURE/]
	[ASCIZ /
FILE BEING MODIFIED/]
REPEAT 8,<0
>
	[ASCIZ /
NO ROOM/]
	[ASCIZ /
WRITE LOCK ERROR/]
	[ASCIZ /
NOT ENOUGH MONITOR SPACE/]
	[ASCIZ /
PARTIAL ALLOCATION ONLY/]
	[ASCIZ /
BLOCK NOT FREE/]

PDP:	IOWD	LPDL,PDLIST

XLIST
LIT
LIST

UU(PDLIST,LPDL)
UU(IBUF,3)
UU(OBUF,3)
UU(LOOKBF,EXLLEN)
U(PPN)
U(STRNAM)
U(FILE)
U(EXT)
ALCEND:	END	ALCFIL