;-*-MIDAS-*-

title initialize PWORD database

x=:0				   ;super temporary
a=:1
b=:2
c=:3
d=:4
e=:5
ct=:6
t=:7				   ;temporary arithmetic register
tt=:10				   ;temporary arithmetic register, T+1

dski=:11
dsko=:12
lsrc==13			   ;channel for LSRTNS

sp=:17
p==:sp

call=:pushj sp,


DEFINE SYSCAL A,B
	.CALL [SETZ ? SIXBIT/A/ ? B ((SETZ))] TERMIN

loc 2000

buffer:	block 2000

pwpage==buffer/2000

.insrt SYSEN1;PWFILE >

pdl:	-100,,pdl
	block 100

go:	move sp,pdl
	movei a,lsrc		   ;A <- channel for LSRTNS
	syscal OPEN,[ %clbit,,.uio ? %climm,,dsko ? [sixbit /DSK/]
		      [sixbit /BIG/] ? [sixbit /DAT/] ? [sixbit /CSTACY/] ]
	  .lose %lsfil
	move t,[444400,,buffer]
	setzm pwcnt		   ;Nothing yet.
	setom atoapl		   ;We allow applications
	setom pwordt		   ;Set no date override
	setom pwordt+1
	setom pwordt+2
	setom pwinit
	setom pwdone
	setzm pwrbfp
	setom pwgrdm
	setom pwgrdm+1
	setom pwgrdm+2
	setom pwgrdm+3
	setom pwgrdm+4
	setom pwgrdm+5
	setom pwgrdm+6
	setom pwgrdm+7
	setom pwgrdm+10
	setom pwgrdm+11
	setom pwgrdm+12
	setom pwgrdm+13
	setom pwgrdm+14
	setom pwgrdm+15
	setom pwgrdm+16
	setom pwgrdm+17
..foo==0
irp gr,,[USER,DAY,DIAL,TURIST,GRP.04,GRP.05,GRP.06,GRP.07,GRP.08,GRP.09,GRP.10,GRP.11,GRP.12,GRP.13,GRP.14,GRP.15] 
	move x,[sixbit /gr/]
	movem x,pwgnam+..foo
  ..foo==..foo+1
TERMIN

	.suset [.runame,,pwuhak]
	.suset [.rjname,,pwjhak]

	move t,[444400,,buffer]
	movei tt,2000
	syscal SIOT,[ %climm,,dsko ? t ? tt]
	  .lose %lsfil
	setzm buffer		   ; Clear the buffer
	move x,[buffer,,buffer+1]
	blt x,buffer+1777
	move t,[444400,,buffer]	   ; Write 6 blank pages to disk
	movei tt,2000
	syscal SIOT,[ %climm,,dsko ? t ? tt]
	  .lose %lsfil
	move t,[444400,,buffer]
	movei tt,2000
	syscal SIOT,[ %climm,,dsko ? t ? tt]
	  .lose %lsfil
	move t,[444400,,buffer]
	movei tt,2000
	syscal SIOT,[ %climm,,dsko ? t ? tt]
	  .lose %lsfil
	move t,[444400,,buffer]
	movei tt,2000
	syscal SIOT,[ %climm,,dsko ? t ? tt]
	  .lose %lsfil
	move t,[444400,,buffer]
	movei tt,2000
	syscal SIOT,[ %climm,,dsko ? t ? tt]
	  .lose %lsfil
	move t,[444400,,buffer]
	movei tt,2000
	syscal SIOT,[ %climm,,dsko ? t ? tt]
	  .lose %lsfil
	move t,[444400,,buffer]	   ; Provide 8 pages of emptyness
	movei tt,2000
	syscal SIOT,[ %climm,,dsko ? t ? tt]
	  .lose %lsfil
	move t,[444400,,buffer]
	movei tt,2000
	syscal SIOT,[ %climm,,dsko ? t ? tt]
	  .lose %lsfil
	move t,[444400,,buffer]
	movei tt,2000
	syscal SIOT,[ %climm,,dsko ? t ? tt]
	  .lose %lsfil
	move t,[444400,,buffer]
	movei tt,2000
	syscal SIOT,[ %climm,,dsko ? t ? tt]
	  .lose %lsfil
	move t,[444400,,buffer]
	movei tt,2000
	syscal SIOT,[ %climm,,dsko ? t ? tt]
	  .lose %lsfil
	move t,[444400,,buffer]
	movei tt,2000
	syscal SIOT,[ %climm,,dsko ? t ? tt]
	  .lose %lsfil
	move t,[444400,,buffer]
	movei tt,2000
	syscal SIOT,[ %climm,,dsko ? t ? tt]
	  .lose %lsfil
	move t,[444400,,buffer]
	movei tt,2000
	syscal SIOT,[ %climm,,dsko ? t ? tt]
	  .lose %lsfil
	.close dsko,
	.logout 1,

end go
