Trailing-Edge
-
PDP-10 Archives
-
decus_20tap2_198111
-
decus/20-0067/putrec.mac
There are 4 other files named putrec.mac in the archive. Click here to see a list.
TITLE FILE
ENTRY PUTREC,OPEFIL,CLOFIL,CHECK
T1=1
T2=2
T3=3
T4=4
N=10
CH=11
PTR=16
OF=17
P=17
;HERE TO SEE IF A FILE DOES EXIST.
;
;CALL: ENTER MACRO CHECK USING FILENAME, PPN.
; [HERE IF ERROR]
; [HERE IF O.K.]
CHECK: MOVE T1,[XWD 400000,17] ;CHANNEL.
MOVSI T2,'DSK' ;DEVICE.
SETZM T3 ;NO BUFFERS.
OPEN OF,T1 ;GRAB DEVICE.
JRST OPEERR ;OPEN ERROR.
MOVE T1,(PTR) ;GET A POINTER.
MOVE T1,(T1) ;GET A REAL POINTER.
MOVE T2,1(T1) ;GET THE EXTENSION.
MOVE T1,(T1) ;GET THE NAME.
SETZM T3 ;CLEAR DATE/TIME WORD.
MOVE T4,1(PTR) ;GET POINTER TO PPN.
MOVE T4,(T4) ;GET PPN.
LOOKUP OF,T1 ;OPEN FILE.
OPEERR: JRST [OUTSTR [ASCIZ "? CAN'T OPEN INPUT FILE.
"]
POPJ P,]
RELEASE 17, ;CLEAR CHANNEL.
AOS (P) ;INCREMENT RETURN.
POPJ P, ;ERROR.
;HERE TO OPEN A FILE CALLED FROM COBOL VIA
;THE FOLLOWING SEQUENCE:
;
; ENTER MACRO OPEFIL USING "FILENAME"
;
;"FILENAME" IS A DISPLAY-6 ITEM THAT IS DEFINED AS FOLLOWS:
;
; XX FILENAME.
; XX NAME PIC X(6).
; XX EXT PIC X(6).
OPEFIL: MOVSI T1,(1B0) ;ASCII LINE AND PHY. DEVICE.
MOVSI T2,'DSK' ;USE DISK.
MOVSI T3,OBUF ;BUFFER HEADER.
OPEN OF,T1 ;GRAB THE DEVICE.
JRST OUTERR ;TYPE ERROR.
MOVE T1,(PTR) ;FETCH BYTE POINTER.
MOVE T1,(T1) ;FETCH ADDRESS OF NAME.
HLLZ T2,1(T1) ;FETCH EXTENSION.
MOVE T1,(T1) ;FETCH NAME.
SETZM T3 ;CLEAR DATE TIME.
MOVE T4,1(PTR) ;FETCH POINTER TO PPN.
MOVE T4,(T4) ;GET PPN.
ENTER OF,T1 ;CREATE FILE.
JRST OUTERR ;DIE.
POPJ P, ;RETURN TO CALLER.
;HERE TO WRITE A RECORD.
;
;CALL: ENTER MACRO PUTREC USING "RECORD"
; [RETURN]
;
;THE RECORD MUST BE A DISPLAY-7 RECORD.
PUTREC: MOVE PTR,(PTR) ;GET ACTUAL POINTER.
MOVE T1,(PTR) ;GRAB BYTE POINTER TO DATA.
MOVE T2,1(PTR) ;GET THE CHARACTER COUNTER.
SETZM N ;CLEAR SPACE COUNTER.
LOOP: ILDB CH,T1 ;GET A CHARACTER.
CAIN CH," " ;SKIP IF NOT SPACE.
AOJA N,LOOP2 ;GET NEXT.
JUMPE N,LOOP1 ;JUMP IF NO SPACES YET.
PUSH P,CH ;AVE NON-SPACE.
MOVEI CH," " ;LOAD A SPACE.
PUSHJ P,PUT ;WRITE IT.
SOJG N,.-1 ;FILL IN PSACES EATEN.
POP P,CH ;RESTORE THAT CHARACTER.
LOOP1: PUSHJ P,PUT ;WRITE THIS CARACTER.
LOOP2: SOJG T2,LOOP ;JUMP IF SOMETHING LEFT.
MOVEI CH,15 ;LOAD A RETURN.
PUSHJ P,PUT ;WRITE IT.
MOVEI CH,12 ;AND A LINE FEED.
JRST PUT ;WRITE IT.
;HERE TO WRITE A CHARACTER.
PUT: SOSGE OBUF+2 ;DECREMENT AND TEST CHARACTER COUNT.
JRST WRITE ;WRITE IT.
IDPB CH,OBUF+1 ;SAVE CHARACTER.
POPJ P, ;RETURN.
WRITE: OUT OF,0 ;WRITE THE BUFFER.
JRST PUT ;CONTINUE.
OUTERR: OUTSTR [ASCIZ "?OUTPUT ERROR
"]
EXIT
OBUF: BLOCK 3
;HERE TO CLOSE THE FILE AND RELEASE THE CHANNEL.
;
;CALL: ENTER MACRO CLOFIL.
; [RETURN]
CLOFIL: CLOSE OF, ;CLOSE THE FILE.
RELEASE OF, ;RELEASE THE CHANNEL.
POPJ P, ;RETURN.
END