Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-06 - 43,50363/filset.mac
There are no other files named filset.mac in the archive.
         TITLE   FILSET
COMMENT!         FILE SPECIFICATION UNGARBAGER

CALLING SEQUENCE:
         MOVEI   4,INPUT
         MOVEI   3,SWITCH
         MOVE    2,[OPENBLOCK,,LOOKUPBLOCK]
         JSP     1,FILSPC
         (ERROR RETURN)
         (NORMAL RETURN)
    "INPUT" IS THE INITIAL RESUMPTION ADDRESS OF A COROUTINE THAT PUTS AN
ASCII CHARACTER IN AC2 AND RETURNS BY AC4.  FOR EXAMPLE:
         INCHWL  2
         JSP     4,(4)
         JRST    .-2
UNPRINTABLE ASCII (EXCEPT NULL) AND LOWER CASE OTHER THAN LETTERS ARE ILLEGAL.
FILSET WILL CONVERT THE ASCII INTO SIXBIT (LOWER CASE LETTERS INTO UPPER) AND
FLAG DELIMITERS WITH BITS 28 & 29 (SIXBIT CODE IN 30-35).  BIT 28 FLAGS FILE
DELIMITERS: NULL,COMMA,EQUALITY (LEFT ARROWS ARE CONVERTED INTO EQUALITY; NULLS
INTO THE 36 BIT VALUE -" ").  BIT 29 FLAGS FIELD DELIMITERS:  .:[]<>/ AND BLANK.
THE ABOVE CHARACTERS ARE ALWAYS DELIMITERS EXCEPT IN (SINGLE) QUOTED STRINGS
AND OCTAL SPECIFICATIONS (# FOLLOWED BY ANY NUMBER OF OCTAL DIGITS; FIELD
TERMINATED BY A NON-OCTAL DIGIT).
    "SWITCH" IS THE INITIAL RESUMPTION ADDRESS OF A COROUTINE THAT PROCESSES
A SWITCH AND RETURNS BY AC3.  THE SWITCH ROUTINE READS SWITCH CHARACTERS (IN
DELIMITER FLAGGED SIXBIT) INTO AC2 BY INVOKING THE FILSET CONVERSION ROUTINE
(BY EXECUTING THE INSTRUCTION: JSP 1,(1)). WHENEVER FILSET DETECTS A DELIMITING
FORWARD SLASH, IT INVOKES THE SWITH ROUTINE (AC2 WILL CONTAIN THE SLASH) AND
EXPECTS THE SWITCH ROUTINE TO READ ALL CHARACTERS UP TO AND INCLUDING THE
FIRST NON-SWITCH CHARACTER WHICH IS RETURNED IN AC2 WHEN SWITCH SUSPENDS ITSLF.
    TO READ THE FIRST SIX CHARS OF A NAME (A NAME IS A SET OF CONSECUTIVE
NON-DELIMITING CHARACTERS), SWITCH CAN READ THE FIRST CHARACTER OF THE NAME
INTO AC2 AND <JSP 3,FILNAM>.  NOTE THAT AC3 MUST BE SAVED FIRST.  THE NAME
(IN SIXBIT, LEFT ADJUSTED AND PADDED WITH BLANKS) WILL BE FOUND IN LOCATION
FILVAL.  AC2 WILL CONTAIN THE DELIMITER THAT TERMINATED THE NAME.
    TO READ AN OCTAL NUMBER, SWITCH CAN READ THE FIRST CHARACTER OF THE NUMERIC
FIELD INTO AC2 AND <JSP 3,FILNUM>.  THE MAGNITUDE OF THE NUMBER WILL BE FOUND
IN LOCATION FILVAL AND THE OCTAL NUMBER FLAGS (SEE BELOW)  WILL BE FOUND IN
LOCATION FILNFL.  AC2 WILL CONTAIN THE CHARACTER THAT DELIMITED THE NUMERIC
FIELD.

    AFTER A NORMAL RETURN, AC2 WILL CONTAIN THE TERMINATING DELIMITER IN ASCII
AND AC3 WILL CONTAIN FLAGS INDICATING  FIELDS SET BY FILSET (SEE FIELD FLAGS).
IF FILSET IS RESUMED (I.E. BY  JSP 1,(1)), IT WILL ASSUME THAT AC2 HAS BEEN
LOADED WITH POINTERS TO A NEW PAIR OF OPEN AND LOOKUP ARGUMENT BLOCKS AND THAT
THE OLD INPUT AND SWITCH RESUMPTION ADDRESSES ARE TO BE USED.

  AFTER AN ERROR RETURN, AC2 WILL CONTAIN AN ERROR CODE. SEE END OF LISTING.

FILSET USES ACCUMULATORS 1,2,3 AND 4.  THE INPUT AND SWITCH ROUTINES SHOULD
NOT READ OR MODIFY THESE EXCEPT AS NOTED ABOVE.     !
         SUBTTL  **** MISCELLANEA ****
         TWOSEG  <HSORG=400000>

         ENTRY   FILSPC
         INTERN  FILNAM,FILNUM,FILVAL,FILNFL,FILCNT

         OPDEF   GOTO[JRST]

D==100           ;FIELD DELIMIT FLAG.
DD==200          ;FILE DELIMIT FLAG.
DEL==DD+D
QUOTE=="'"-" "   ;SIXBIT SINGLE QUOTE.

         ;ACCUMULATOR ASSIGNMENTS:
DR==1
C==2
AR==3
IR==4

         ;FIELD FLAGS:
DEVFLG==1B30
FILFLG==1B31
EXTFLG==1B32
PRJFLG==1B33
PRGFLG==1B34
PROFLG==1B35

         ;OCTAL NUMBER FLAGS:
OVF==1B31        ;OVERFLOW,
LS==1B32         ;LEADING (DELIMITING) SPACES,
TS==1B33         ;TRAILING (DELIMITING) SPACES,
MS==1B34         ;NEGATIVE SIGN,
DS==1B35         ;AT LEAST ONE DIGIT.
         SUBTTL  **** LOW SEGMENT ****
         RELOC   0

IRS:     BLOCK   1                 ;ACCUMULATOR SAVE LOCATIONS:
ARS:     BLOCK   1
CS:      BLOCK   1
RETSAV:  BLOCK   1
ARGBLK:  BLOCK   1                 ;OPEN BLOCK,,LOOKUP BLOCK
FLDFLG:  BLOCK   1                 ;FIELD SET FLAGS.
FILCNT:COUNT:   BLOCK   1
FILNFL:NUMFLG:NAMPNT:  BLOCK  1
FILVAL:NUMBER:NAME:    BLOCK  1
         SUBTTL  **** HIGH SEGMENT ****
         RELOC   HSORG
;ENTRY POINT FILSPC--BEGIN UNGARBAGING FILE SPECIFICATION.
FILSPC:  MOVEM   AR,ARS            ;SAVE SWITCH RESUMPTION ADDRESS.
         MOVEM   IR,IRS            ;SAVE INPUT RESUMPTION ADDRESS.
         MOVEM   DR,RETSAV         ;SAVE RETURN ADDRESS.
         MOVEI   DR,NORMOD         ;INITIALIZE DELIMITER FLAG RESUMPTION.
;RESUMPTION POINT FILRES--RESUME UNGARBAGING WITH NEXT FILE.
FILRES:  MOVEM   C,ARGBLK          ;SAVE OPEN AND LOOKUP BLOCK ADDRESSES.
         CLEARM  FLDFLG            ;CLEAR FIELD SET FLAGS.
         GOTO    PRENEW            ;BEGIN WITH NEW FIELD.


;COROUTINE--GET SIXBIT--RESUMPTION ADDRESS IS NXTCHR--RETURNS TO (IR)
NXTCHR:  EXCH    IR,IRS            ;SAVE RETURN,,RESORE INPUT RESUMPTION
         JSP     IR,(IR)           ;RESUME ASCII INPUT.
         EXCH    IR,IRS            ;SAVE ASCII RESUMPTION,, RESTORE RETURN.
         ANDI    C,177             ;CLEAR JUNK BITS.
         CAIG    C,"Z"+" "         ;TRAP ILLEGAL ASCII:
         CAIN    C,"@"+" "         ;    1)NON-ALPHABETIC LOWER CASE
         GOTO    ILLASC            ;    2)NON-NULL CONTROL.
         JUMPE   C,NXTEND
         CAIGE   C," "
         GOTO    ILLASC
         CAIL    C,"A"+" "         ;CONVERT LOWER CASE TO UPPER CASE.
         SUBI    C," "
NXTEND:  SUBI    C," "             ;CONVERT ASCII INTO SIXBIT.
         GOTO    (IR)
;COROUTINE--FLAG DELIMITERS & CONVERT OCTAL INTO SIXBIT--RESUMPTION AND RETURN
;                                                                       =(DR)
NORMOD:  JSP     IR,NXTCHR         ;GET A SIXBIT CHARACTER.
NORMOX:  CAIN    C,'#'
         GOTO    OCTMOD            ;ENTER OCTAL MODE.
         CAIN    C,QUOTE
         GOTO    QUOMOD            ;ENTER QUOTED MODE.
         CAIN    C,'_'
         MOVEI   C,'='             ;CONVERT _ INTO =.
         CAIE    C,','
         CAIN    C,'='
         ORI     C,DD              ;FLAG FILE DELIMITERS.
         CAIE    C,' '             ;FLAG FIELD DELIMITERS:
         CAIN    C,'.'
         ORI     C,D
         CAIE    C,'/'
         CAIN    C,':'
         ORI     C,D
         CAIE    C,'<'
         CAIN    C,'>'
         ORI     C,D
         CAIE    C,'['
         CAIN    C,']'
         ORI     C,D
         JSP     DR,(DR)           ;RETURN FLAGGED SIXBIT.
         GOTO    NORMOD

QUOMOD:  JSP     IR,NXTCHR
         TRNE    C,DEL             ;CHECK FOR NULL (END OF INPUT).
         GOTO    EUMQUO            ;ERROR IF END OF LINE IN QUOTED MODE.
         CAIE    C,QUOTE           ;PASS ALL NON-QUOTES UP TO THE NEXT FREE
         GOTO    QUOPSS            ;QUOTE AS NON-DELIMITERS.
         JSP     IR,NXTCHR
         CAIE    C,QUOTE           ;IF QUOTE IS NOT FREE,
         GOTO    NORMOX            ;PASS AS QUOTE AND REMAIN IN QUOTED MODE.
QUOPSS:  JSP     DR,(DR)
         GOTO    QUOMOD

OCTMOD:  JSP     IR,NXTCHR
         CAIL    C,'0'             ;UNTIL NEXT NON-OCTAL DIGIT,
         CAILE   C,'7'             ;PASS EACH PAIR OF OCTAL DIGITS
         GOTO    NORMOX            ;AS ONE NON-DELIMITING SIXBIT CHARACTER.
         SUBI    C,'0'
         LSH     C,3               ;IF THE LAST OCTAL DIGIT IS UNMATCHED,
         MOVEM   C,CS              ;ASSUME AN EXTRA ZERO.
         JSP     IR,NXTCHR
         CAIL    C,'0'
         CAILE   C,'7'
         GOTO    OCTSNG
         SUBI    C,'0'
         ADD     C,CS
         JSP     DR,(DR)
         GOTO    OCTMOD
OCTSNG:  EXCH    C,CS
         JSP     DR,(DR)
         MOVE    C,CS
         GOTO    NORMOX
;COROUTINE--ASSEMBLE NAME--RESUMPTION=ASNAME--RETURN=(AR)
ASNAME:  MOVEI   IR,6              ;LIMIT NAME TO 6 CHARACTERS.
         MOVEM   IR,COUNT          ;(IGNORE ALL BUT FIRST 6)
         MOVE    IR,[POINT 6,NAME] ;NAME WILL BE LEFT ADJUSTED
         MOVEM   IR,NAMPNT         ;AND PADDED WITH BLANKS.
         CLEARM  NAME
         GOTO    ASNBEG            ;ENTER ASSEMBLY LOOP.
ASNRES:  SOSL    COUNT
         IDPB    C,NAMPNT          ;READ ALL CHARACTERS UP TO NEXT DELIMITER.
         JSP     DR,(DR)
ASNBEG:  TRNE    C,DEL
         GOTO    (AR)
         GOTO    ASNRES

;COROUTINE--ASSMEMBLE NUMBER--RESUMPTION ADDRESS=ASONUM--RETURN ADDRESS=(AR)
ASONUM:  CLEARM  NUMBER
         CLEARM  NUMFLG
ASOLS:   CAIE    C,' '+D           ;SKIP LEADING SPACES.
         GOTO    ASONLS
         JSP     DR,(DR)
         MOVEI   IR,LS             ;INDICATE LEADING SPACES.
         ORM     IR,NUMFLG
         GOTO    ASOLS
ASONLS:  CAIE    C,'-'             ;SKIP LEADING NEGATIVE SIGN.
         GOTO    ASONMS
         MOVEI   IR,MS             ;INDICATE LEADING SIGN.
         ORM     IR,NUMFLG
ASONMS:  CAIL    C,'0'             ;ADD OCTAL DIGITS TO RIGHT END OF NUMBER.
         CAILE   C,'7'
         GOTO    ASOND
         SUBI    C,'0'
         EXCH    C,NUMBER
         TLNN    C,700K            ;CHECK FOR OVERFLOW.
         GOTO    ASONOV
         MOVEI   IR,OVF            ;INDICATE OVERFLOW.
         ORM     IR,NUMFLG
ASONOV:  LSH     C,3
         ORM     C,NUMBER
         MOVEI   IR,DS             ;INDICATE DIGITS.
         ORM     IR,NUMFLG
         JSP     DR,(DR)
         GOTO    ASONMS
ASOND:   CAIE    C,' '+D           ;SKIP TRAILING BLANKS.
         GOTO    (AR)
         MOVEI   IR,TS             ;INDICATE TRAILING SPACES.
         ORM     IR,NUMFLG
         JSP     DR,(DR)
         GOTO    ASOND

FILNAM=ASNAME
FILNUM=ASONUM
;COROUTINE--FILL IN OPEN AND LOOKUP BLOCKS
PRENEW:  JSP     DR,(DR)           ;LOOK FOR BEGINNING OF NEW FIELD:
NEWFLD:  TRNN    C,DEL             ;NON-DELIMITER STARTS NAME FIELD.
         GOTO    NAMFRS
ISDELI:  TRNE    C,DD              ;CERTAIN DELIMITERS(=,NULL) TERMINATE SPEC.
         GOTO    ENDSPC
         CAIN    C,' '+D           ;DELIMITING BLANKS ARE IGNORED.
         GOTO    PRENEW
         CAIN    C,'.'+D           ;DELIMITING PERIOD MEANS FILENAME EXTENSION.
         GOTO    FILEXT
         CAIN    C,'/'+D
         GOTO    SWITCH
         CAIN    C,':'+D           ;NULL DEVICES ARE PERMITTED (HERE).
         GOTO    NAMFRS            ;(ASNAME MAKES LEADING DECISIONS)
         CAIN    C,'<'+D           ;INDICATES PROTECTION CODE.
         GOTO    PROTCT
         CAIN    C,'>'+D           ;ERROR EXCEPT AFTER PROTECTION CODE.
         GOTO    EUMANG
         CAIN    C,'['+D           ;INDICATES PPN.
         GOTO    PRJPRG
         CAIN    C,']'+D           ;ERROR EXCEPT AFTER PROGRAMMER NUMBER.
         GOTO    EUMSQU
         HALT                      ;SHOULD NOT GET THIS FAR.

ENDSPC:  ADDI    C," "             ;CONVERT FINAL DELIMITER INTO ASCII.
         ANDI    C,177
         MOVE    AR,FLDFLG         ;GET FIELD SET FLAGS.
         EXCH    DR,RETSAV         ;GET RETURN ADDRESS.
         JSP     DR,1(DR)          ;GIVE NORMAL RETURN.
         EXCH    DR,RETSAV         ;SAVE REURN ADDRESS.
         GOTO    FILRES            ;RESTART FILSET.

FILEXT:  JSP     DR,(DR)           ;GET FIRST CHARACTER OF EXTENSION (OR DELIM).
         JSP     AR,ASNAME         ;ASSEMBLE NAME.
         MOVE    IR,NAME
         HRRZ    AR,ARGBLK         ;GET ADDRESS OF LOOKUP BLOCK.
         HLLM    IR,1(AR)          ;DEPOSIT EXTENSION.
         MOVEI   IR,EXTFLG         ;INDICATE EXTENSION SET.
SETFLG:  ORM     IR,FLDFLG
         GOTO    ISDELI

NAMFRS:  JSP     AR,ASNAME         ;ASSEMBLE NAME.
         MOVE    IR,NAME
         CAIN    C,':'+D           ;IF DELIMITED BY : THEN
         GOTO    SETDEV            ;NAME IS DEVICE NAME
         HRRZ    AR,ARGBLK         ;ELSE NAME IS FILE NAME.
         MOVEM   IR,0(AR)          ;DEPOSIT FILE NAME.
         MOVEI   IR,FILFLG         ;GET FILE NAME SET FLAG.
         GOTO    SETFLG
SETDEV:  HLRZ    AR,ARGBLK
         MOVEM   IR,1(AR)          ;DEPOSIT DEVICE NAME.
         MOVEI   IR,DEVFLG         ;GET DEVICE SET FLAG.
         ORM     IR,FLDFLG         ;INDICATE DEVICE FIELD SET.
         GOTO    PRENEW

SWITCH:  MOVE    AR,ARS            ;GET SWITCH ROUTINE RESUMPTION ADDRESS.
         JUMPE   AR,ENOSWC         ;ERROR IF NO SWITCH ROUTINE.
         JSP     AR,(AR)           ;BEGIN SWITCH ROUTINE.
         MOVEM   AR,ARS            ;SAVE SWITCH RESUMPTION ADDRESS.
         GOTO    NEWFLD            ;PROCESS NEXT FIELD.

PROTCT:  JSP     DR,(DR)           ;GET FIRST PROTECTION DIGIT.
         JSP     AR,ASONUM         ;ASSEMBLE AN OCTAL NUMBER.
         MOVE    IR,NUMFLG         ;READ NUMBER FLAGS.
         TRNE    IR,OVF+MS         ;TRAP ON OVERFLOW OR NEGATIVE SIGN.
         GOTO    ENMPRO
         TRNN    IR,DS             ;TRAP ON NO DIGITS.
         GOTO    ENOPRO
         MOVE    IR,NUMBER         ;GET THE NUMBER.
         JUMPL   IR,EPROOV         ;ERROR IF PROTECTION CODE GREATER THAN 777.
         CAILE   IR,777
         GOTO    EPROOV
         HRRZ    AR,ARGBLK         ;DEPOSIT PROTECTION CODE.
         DPB     IR,[POINT 9,2(AR),8]
         MOVEI   IR,PROFLG         ;INDICATE PROTECTION SET.
         ORM     IR,FLDFLG
         CAIE    C,'>'+D           ;VERIFY PROTECTION DELIMITER.
         GOTO    EDLPRO
         GOTO    PRENEW            ;PROCESS NEXT FIELD.

PRJPRG:  JSP     DR,(DR)           ;GET FIRST PROJECT DIGIT (OR COMMA).
         JSP     AR,ASONUM         ;ASSEMBLE PROJEXT NUMBER.
         MOVE    IR,NUMFLG         ;READ NUMBER FLAGS.
         TRNN    IR,OVF+MS+DS      ;IF NO PROJECT NUMBER, SKIP TO PROGRAMMER.
         GOTO    PRGNUM
         TRNE    IR,OVF+MS         ;ERROR IF OVERFLOW OR NEGATIVE SIGN.
         GOTO    ENMPRJ
         MOVE    IR,NUMBER
         TLNE    IR,-1             ;ERROR IF MORE THAN 18 BITS.
         GOTO    EPRJOV
         HRRZ    AR,ARGBLK
         HRLM    IR,3(AR)          ;DEPOSIT PROJECT NUMBER.
         MOVEI   IR,PRJFLG
         ORM     IR,FLDFLG         ;INDICATE PROJECT SET.
PRGNUM:  CAIE    C,','+DD          ;PROJECT NUMBER MUST BE TERMINATED WITH COMMA
         GOTO    EDLPRJ
         JSP     DR,(DR)           ;GET FIRST PROGRAMMER DIGIT (OR ]).
         JSP     AR,ASONUM         ;ASSEMBLE PROGRAMMER NUMBER.
         MOVE    IR,NUMFLG         ;READ ASSEMBLY FLAGS.
         TRNN    IR,OVF+MS+DS      ;IF NO NUMBER, SKIP PROGRAMMER SET.
         GOTO    PPNEND
         TRNE    IR,OVF+MS         ;ERROR IF OVERFLOW OR NEGATIVE SIGN.
         GOTO    ENMPRG
         MOVE    IR,NUMBER
         TLNE    IR,-1             ;ERROR IF MORE THAN 18 BITS.
         GOTO    EPRGOV
         HRRZ    AR,ARGBLK         ;DEPOSIT PROGRAMMER NUMBER.
         HRRM    IR,3(AR)
         MOVEI   IR,PRGFLG         ;INDICATE PROGRAMMER SET.
         ORM     IR,FLDFLG
PPNEND:  CAIE    C,']'+D           ;PROGRAMMER MUST BE TERMINATED WITH ].
         GOTO    EDLPRG
         GOTO    PRENEW
;ERROR ROUTINES: (JUST SET ERROR CODES)
ILLASC:  MOVSI   C,(C)             ;ILLEGAL ASCII INPUT.
         AOJA    C,ERRET           ;ERROR CODE=1
EUMQUO:  MOVEI   C,2               ;INPUT END(NULL) IN QUOTED STRING.
         GOTO    ERRET
EUMANG:  MOVEI   C,3               ;UNMATCHED RIGHT ANGLE BRACKET.
         GOTO    ERRET
EUMSQU:  MOVEI   C,4               ;UNMATCHED RIGHT SQUARE BRACKET.
         GOTO    ERRET
ENOSWC:  MOVEI   C,5               ;SWITCH IN FILESPEC BUT NO SWITCH ROUTINE.
         GOTO    ERRET
ENMPRO:  TRNN    IR,MS
         GOTO    EPROOV
         MOVEI   C,6               ;NEGATIVE SIGN IN PROTECTION CODE.
         GOTO    ERRET
EPROOV:  MOVEI   C,7               ;PROTECTION CODE TOO LARGE.
         GOTO    ERRET
ENOPRO:  MOVEI   C,10              ;NO DIGITS IN PROTECTION CODE.
         GOTO    ERRET
EDLPRO:  MOVEI   C,11              ;IMPROPERLY DELIMITED PROTECTION CODE.
         GOTO    ERRET
ENMPRJ:  TRNN    IR,MS
         GOTO    EPRJOV
         MOVEI   C,12              ;NEGATIVE SIGN IN PROJECT NUMBER.
         GOTO    ERRET
EPRJOV:  MOVEI   C,13              ;PROJECT NUMBER TOO LARGE.
         GOTO    ERRET
EDLPRJ:  MOVEI   C,14              ;IMPROPERLY DELIMITED PROJECT NUMBER.
         GOTO    ERRET
ENMPRG:  TRNN    IR,MS
         GOTO    EPRGOV
         MOVEI   C,15              ;NEGATIVE SIGN IN PROGRAMMER NUMBER.
         GOTO    ERRET
EPRGOV:  MOVEI   C,16              ;PROGRAMMER NUMBER TOO LARGE.
         GOTO    ERRET
EDLPRG:  MOVEI   C,17              ;IMPROPERLY DELIMITED PROGRAMMER NUMBER.

ERRET:   JSP     DR,@RETSAV        ;GIVE ERROR RETURN.
         HALT                      ;JUST IN CASE SOME IDIOT TRIES TO RESUME
                                   ;THIS PROGRAM AFTER AN ERROR.

         LIT
         END