/ CCLX3.PA - Command Control Language
/ Version 01.22  (Aerospace version number of this file.)
/
/ Remembrance Code
/
/ CCL remembers up to 15 command lines.  The length of each
/ is specified by the constants AREA1, AREA2, . . ., AREA15.
/ Lines are stored two characters per word (subtract one
/ from the character count for the terminationg zero) in
/ block 65 on the system device.

/ The block is read into 04000-04377.  REMADR finds the
/ first address of a remember area by summing the lengths
/ of the preceding areas (stored in REMTBL).  Each remember
/ area has the following format:

/ Word 0:       In-use flag, 7777 means valid remembrance.
/ Word 1:       Command dependent information.
/ Words 2-AREAn Command line without keyword or succeeding
/               spaces, packed in 6-bit, and terminated by
/               6-bit zero.

/ Block number in system area containing remembrances.
        REMBLOCK=65

/ Field 0 addresser for remembrance block.
        REMSPACE=4000

/ Hold command-dependent twelve bits.
DEPN,   0
/ Subroutine to look up addr of remember area.
/ Call with remember area in Ac.
REMADR, 0               / Serves as recall flag--if nonzero,
        CIA             / a command line was recalled.
        DCA LCOUNT
        TAD (REMTBL-1
        DCA XR
REMAD0, TAD I XR        / Sum length of last (0 for area 1).
        ISZ LCOUNT      / Reached our area?
        JMP REMAD0      / No.
        DCA XR2         / Save address for LPUT.
        TAD I XR        / Get length of our area.
        CMA             / Makes -length-1.
        DCA LCOUNT      / Set counter.
        JMP I REMADR
LCOUNT, NIL

REMTBL, REMSPACE-1
        AREA1
        AREA2
        AREA3
        AREA4
        AREA5
        AREA6
        AREA7
        AREA8
        AREA9
        AREA10
        AREA11
        AREA12
        AREA13
        AREA14
        AREA15
/ RCLREM
/ Move specified remember area into current line.  If empty,
/ print a bad syntax error message and return to OS/8.

RCLREM, 0
        TAD I (FLAG     / Get number of remember area.
        AND (170
        SNA             / Zero?
        JMP I RCLREM    / Yes- nothing to recall.
        CLL RAR         / Shift number to right.
        RTR
        JMS REMADR      / Add up addr of remember area.
        JMS I (RDREM    / Load rem block into rem buffer.
        JMP I (REMERR   / Error return.
        JMS LGET        / Get first word--in-use flag.
        IAC
        SZA CLA         / Is it valid?
        JMP I (REMERR   / No- can't remember.
        JMS LGET        / Get dependent information.
        DCA DEPN
        TAD (BEGLN-1    / Set pntr to command line.
        DCA XR
        TAD (BEGLN-1    / First char will also be the first
        DCA I (LBEGIN   / significant char.
RECAL1, JMS LGET
        DCA LGET
        TAD LGET
        JMS I (ROTL
        RAL
        JMS I (PUTF
        JMP I RCLREM
        TAD LGET
        JMS I (PUTF
        JMP I RCLREM
        JMP RECAL1

/ Get word from remember buffer.
LGET,   0
        CDF 0
        TAD I XR2
        CDF 10
        JMP I LGET
/ REMEM
/ Move current line to specified remember area.  If the
/ line is too long, print a warning and return as if ok.

REMEM,  NIL
IFDEF   CM56 </ -R switch.
        TAD I (NOREM
RSHUNT, SZA CLA         / -R?
        JMP I REMEM     / Yes- don't remember this time.
        >/*CM56
        TAD I (FLAG
        AND (1000       / Extract do-not-remember bit.
        TAD REMADR      / Combine with recall flag.
        SZA CLA         / Just recalled or do-not-remember?
        JMP I REMEM     / Leave current remembrance alone.
        TAD I (FLAG     / Get number of remember area.
        AND (170
        SNA             / Zero?
        JMP I REMEM     / Yes- exit.
        CLL RAR         / No- shift number to right.
        RTR
        JMS REMADR      / Add up addr of remember area.
        JMS I (RDREM    / Load rem block into rem buffer.
        JMP I (MEMBIG   / Error return.
        STA             / Set in-use flag.
        JMS LPUT
        TAD DEPN        / Store dependent information.
        JMS LPUT
        TAD I (LBEGIN   / Set pntr to command line.
        DCA XR

REMEM1, JMS I (GETF     / Get odd char from command line.
        JMP LZERO       / Return here if zero.
        JMS I (ROTL     / Shift it to left byte.
        DCA LPUT        / Save in temp.
        JMS I (GETF     / Get even char from command line.
        JMP RZERO       / Return here if zero.
        TAD LPUT        / Add on left byte.
        JMS LPUT        / Put chars into remember buffer.
        JMP REMEM1      / Loop.

RZERO,  TAD LPUT        / Get left byte (right is 0).
LZERO,  JMS LPUT        / Put terminater into rem buffer.
        JMS I (WRREM    / Store rem buffer in rem block.
        JMP I (MEMBIG   / Error return.
REMGO,  JMP I REMEM

/ Put word into remember buffer.
LPUT,   0
        CDF 0
        DCA I XR2
        CDF 10
        ISZ LCOUNT      / Area is full?
        JMP I LPUT      / No.
        JMP I (MEMBIG   / Yes.

        PAGE
CDINIT, 0
        TAD I DEFALT
        TAD (-5200
        SZA CLA         /IS THIS A REQUEST FOR A
                        /"SPECIAL DECODE"?
        JMP CDCONT      /NO
        TAD ALTLIM
        DCA OUTLIM      /YES, SET UP THE PROPER LOCATIONS
        TAD ALTDF1
        DCA LIMDIF      /TO GET 1 OUTPUT AND 5 INPUT FILES
        TAD ALTDF2
        DCA BEGDIF      /ALL OF WHICH ARE
                        /5-WORD <DEVICE,NAME> ENTRIES
        DCA I PLKUPS
        TAD (STARNM&177!5200
        DCA I PSTARS    /AND ALLOW *
                        /AS A FILE OR EXTENSION NAME
        TAD (CLA        /STOPS FETCHES IN SPECIAL MODE
        DCA I PSPKG1    /NO HANDLER FETCHES NECESSARY EITHER
                        /SINCE NO LOOKUPS
CDCONT, JMS I (BKA
        STA
        DCA I (OUTSW
        JMS ZEROCD
        TAD I (LBEGIN
        DCA LXR
        JMS I (200      /GET DSK DEVICE NUMBER
        12
        DEVICE DSK
DSKNUM= .-1
        0
        DCA DSKNUM      /ZERO IF ERROR
        JMP I CDINIT

/CONSTANTS NECESSARY TO SUPPORT "SPECIAL DECODE" MODE

ALTLIM, 1-MOFILE-5
ALTDF1, MOFILE+5-MPARAM+5
ALTDF2, 5
PLKUPS, LKUPSW
PSTARS, STARSW
PSPKG1, SPKLG1

BEGDIF, MIFILE-MOFILE
LIMDIF, MIFILE-MPARAM+2
OUTLIM, 1-MIFILE

ZEROCD, 0
        TAD (-42        /AC MAY BE NON-0
        DCA T
        TAD (MOFILE-1
        DCA XR
        DCA I XR        /ZERO COMMAND DECODER OUTPUT AREA
        ISZ T
        JMP .-2
        JMP I ZEROCD

NMOVE,  0
        DCA T           /DEFAULT DEVICE.
        TAD I NMOVE
        ISZ NMOVE
        DCA PT1
        TAD I PT1
        SNA
        TAD T
        SNA
        TAD DSKNUM
        SNA
        IAC
        DCA I PT1
        ISZ PT1
        TAD I PT1       /WAS THERE A SPECIFICATION THERE?
        SZA CLA
        JMP I NMOVE     /YES, DO NOTHING
        TAD I (7601     /USE FIRST OUTPUT NAME,
        SNA CLA
        TAD (NAME1-7601 /ELSE USE CURRENT NAME.
        TAD (7601
        DCA PT0
        TAD I (FLAG
        AND (200        /GET 'COPY EXTENSION' BIT
        SZA CLA
        STA             /COPY 4 WORDS IF BIT 4 WAS ON
        TAD (-3         /OTHERWISE ONLY COPY 3 WORDS
        JMS I (MOVE)
        CDF 10
PT0,    NAME1
        CDF 10
PT1,    0
        JMP I NMOVE
/       TAD (-# OF LOCS TO MOVE
/       JMS MOVE
/       FROM CDF
/       FROM LOC
/       TO CDF
/       TO LOC

MOVE,   0
        DCA T
        TAD I MOVE      /GET FROM CDF
        DCA FRCDF
        ISZ MOVE
        STA
        TAD I MOVE      /GET FROM LOC-1
        DCA XR
        ISZ MOVE
        TAD I MOVE      /GET TO CDF
        DCA TOCDF
        ISZ MOVE
        STA
        TAD I MOVE      /GET TO LOC-1
        DCA XR2
        ISZ MOVE        /POINT TO RETURN
FRCDF,  HLT
        TAD I XR
TOCDF,  HLT
        DCA I XR2
        ISZ T
        JMP FRCDF
        CDF 10
        JMP I MOVE

        PAGE
LC,     40              /0 IF NO LOWER CASE

CCER1,  TAD I (NAMPTR
        JMS NAMERR
CDER3,  TAD ("#
        JMS I (TYPE
        JMS I (PRNAME
        JMS I (PRMESG
        NF

CDER0,  TAD (DEV1-DVNM1
CCER2,  TAD (DVNM1
        JMS NAMERR
        DCA NAME3
        DCA NAME4
        TAD NAME1
        SNA CLA
        JMP I (CDER2    /B DOES NOT EXIST
        TAD ("#
        JMS I (TYPE
        JMS I (PRNAME
        JMS I (PRMESG
        DNE

NAMERR, 0
        DCA NMX
        TAD (-4
        JMS I (MOVE
        CDF 10
NMX,    0
        CDF 10
        NAME1
        JMP I NAMERR

LCCON,  0               /CONVERT UC TO LC!
        TAD (-40
        SNA
        JMP SPACE
        SMA             /LETTER OR NUMBER?
        JMP NOTLC
        IAC
        IAC
        SNA
        JMP LCTGL       /^ = TOGGLE CASE
        TAD I (LCFLG
        TAD ("^-240
SPACE,  TAD (240
        JMS I (TYPE
        TAD I (LCFLG
        SNA
        TAD LC
        JMP LCXIT

LCTGL,  TAD I (LCFLG
        SMA CLA
        STL RAR
        JMP LCXIT

NOTLC,  TAD (240
        JMS I (TYPE
        TAD I (LCFLG
        SMA CLA
        TAD I (TE2
        TAD (-"/
        SNA CLA
LCXIT,  DCA I (LCFLG
        JMP I LCCON


/ Test FLAG against bits in Ac.  If none of the bits set in
/ the Ac are set in FLAG, print "Bad switch" and abort.
SWTCHK, SUBR
        AND I (FLAG
        SZA CLA         / Switch enabled?
        JMP I SWTCHK    / Yes.
        JMP I (CDER4    / Switch Not Allowed Here.

/ Set flag to clear first output file for -NB or -NO switches.
DONBNO, 0               / Used as flag.
        TAD I T         / Get bits to test.
        JMS SWTCHK
        JMP I DONBNO

IFDEF   CM56 </ -R switch.
/ Do not remember if -R was typed.
NOREM,  0               / Used as flag.
        JMP I NOREM     / If remembrance is 0, so what?
        >/*CM56

        PAGE
///     OVLOAD - LOAD SUBROUTINE OVERLAY.  AC=ADDRESS.
/
/       IF AC .LT. 'CRITICAL', OVERLAY IS LOADED FROM CCLX.
/       IF AC .GE. 'CRITICAL', NOTHING IS DONE.
/
/       AC ON RETURN IS FIELD 1 ADDRESS OF SUBROUTINE.
///

OVLOAD, SUBR
        SNA
        TAD (NOPSUB
        DCA T
        CLL
        TAD (-CRITICAL
        TAD T
        SNA SZL CLA
        JMP OVXIT       /.GE. 'CRITICAL' - FIELD 1 SUBR.
        TAD T           /.LT. 'CRITICAL' - OVERLAY SUBR.
        RAL
        RTL
        RTL
        AND (17)        /BLOCK OFFSET.
        TAD F0DISP
        CDF 0
        TAD I (CCLBLC
        CDF 10
        DCA OVBLOK
        TAD T
        AND (377)
        TAD OVCODE
        DCA T           /ENTRY ADDRESS.
        CIF 0
        JMS I (7607)
        210
OVCODE, OVLBAS
OVBLOK, 0
        JMP IOERR
        TAD I T         /CHECK TO MAKE SURE
        TAD (-OVSUBR)   /WE ARE CALLING
        SNA CLA         /AN OVERLAY.
        JMP OVXIT
        JMS I (PRMESG
        OVLMES

OVXIT,  TAD T           /RETURN AC=ADDRESS.
        JMP I OVLOAD

F0DISP, CCLLWA-2000%400+2

RDREM,  0
        CIF 0
        JMS I (7607
        200             /READ 2 PAGES INTO FIELD 0
        4000            /LOCATION 4000
        REMBLOCK
        SKP CLA
        ISZ RDREM
        JMP I RDREM

WRREM,  0
        CIF 0
        JMS I (7607
        4200            /WRITE 2 PAGES FROM FIELD 0
        4000            /LOCATION 4000
        REMBLOCK
        SKP CLA
        ISZ WRREM
        JMP I WRREM

RDMON,  0
        CDF 10
KCIF,   CIF 0
        CLA
        JMS I (7607
        0400            /READ 2 RECORDS
        2000            /LOCATION 2000 FIELD 0
        7               /BLOCK 7,10
        JMP IOERR
        JMP I RDMON

IOERR,  JMS I (PRMESG
        SYSER

EXTLUK, 0
        CIA
        DCA T
XLUK,   TAD I DEF
        SNA             /AT NULL?
        JMP I EXTLUK    /YES
        TAD T           /NO
        SNA CLA         /MATCH?
        JMP MAT         /YES
        ISZ DEF         /NO
        ISZ DEF         /POINT TO NEXT ENTRY
        JMP XLUK        /TRY AGAIN
MAT,    TAD I DEF       /RETURN WITH IT IN AC
        JMP I EXTLUK

TWAIT,  0
        DCA WFL
        JMS BATCH
        TSF
        SZA CLA
        JMP I TWAIT
        ISZ WFL
        ISZ WFL
        ISZ WFL
        JMP .-3
        JMP I TWAIT

BATCH,  0       /SKIP WITH AC=CIF BCHFLD IF BATCH RUNNING.
        CDF 0
        TAD I (7777
        RTL
        SNL CLA
        JMP BATCHX      /BATCH NOT RUNNING.
        TAD I (7777
        AND (70
        TAD KCIF
        ISZ BATCH       /SKIP IF RUNNING.
BATCHX, CDF 10
        JMP I BATCH

WFL,
SPOOLIT,0
        JMS BATCH       /IS BATCH RUNNING?
        JMP I SPOOLIT   /NO
        DCA CB          /YES
        TAD I DEFALT
        TAD (-5200
        SNA CLA
        TAD I DEFALT    /LEAVE 5200 IN AC IF SPECIAL MODE
CB,     HLT             /CIF TO FIELD OF BATCH
        JMS I (BATSPL   /ALLOW BATCH TO SPOOL STUFF
        JMP I SPOOLIT

        PAGE
LCFLG,
PRMESG, 0
        CLA
        TAD I PRMESG
        DCA .+3
        DCA LCFLG       /START IN UC
        JMS PRINT
        HLT
LEAVE,  TAD TYPE
        SZA CLA         /DON'T WAIT IF NOTHING TYPED.
        JMS I (TWAIT
        TCF
FATALFLG,SKP            / To abort, SKP must be changed to
        JMP I (BATERR   / a CIF CDF to the batch field.
        CDF CIF 0
        JMP I (7605

PRWD,   0
        DCA T
        TAD T
TTY212, RTR
        RTR
        RTR
        JMS PCHAR
        TAD T
        JMS PCHAR
        JMP I PRWD

PCHAR,  0
        AND (77
        SNA
        JMP I PCHAR     /IGNORE NULLS
        JMS I (LCCON
/       TAD (240        /REMOVED FOR
/       AND (77
/       TAD (240        /LC OUTPUT...
/       JMS TYPE
        JMP I PCHAR

PRNAME, 0
        CLA STL RAR     /SET CAPS LOCK
        DCA LCFLG
        TAD NAME1
        JMS PRWD
        TAD NAME2
        JMS PRWD
        TAD NAME3
        JMS PRWD
        TAD NAME4
        SNA CLA
        JMP I PRNAME
        TAD (256
        JMS TYPE
        TAD NAME4
        JMS PRWD
        JMP I PRNAME

TYPE,   0
        DCA TE2
        JMS I (BATCH
        JMP TTYOUT
        DCA CIFB
CIFB,   HLT             /REPLACED BY CIF BATCH FIELD
        TAD TE2
        JMS I (BATOUT
        TAD TE2
        TAD BTERRC
        SZA CLA
        JMP I TYPE
        TAD CIFB
        IAC             /CONVERT CIF TO CIF CDF
        DCA FATALFLG
        JMP I TYPE

BTERRC, -"#             /MODIFIED BY RECALL COMMAND.
TTYOUT, TAD TE2
        TAD BTERRC      /DON'T TYPE #'S
        SNA CLA
        JMP I TYPE
        JMS I (KRSSUB   /CHECK ^C
        TAD (-217       /CHECK ^O
        SNA
        JMP I TYPE
        TAD (217-223    /XOFF?
        SZA CLA
        JMP TJUMP
        KCC
        JMS I (KRSSUB   /WAIT FOR XON
        TAD (-221
        SZA CLA
        JMP .-3
        KCC
TJUMP,  JMP .+3
        TSF
        JMP .-1
        TAD TE2
        TLS
        CLA
/       TAD (7000
        DCA TJUMP
        JMP I TYPE

PRINT,  0
        DCA CRLF        /AC NON-0 MEANS DON'T CRLF
        DCA LCFLG
        TAD I PRINT
        ISZ PRINT
        DCA TE
PRINTP, TAD I TE
        JMS PRWD
        TAD I TE
        ISZ TE
        AND (77
        SZA CLA
        JMP PRINTP
        TAD CRLF
        SNA CLA
        JMS CRLF
        JMP I PRINT
TE,     0
TE2,    0

CRLF,   0
        TAD (215
        JMS TYPE
        TAD TTY212
        JMS TYPE
        JMP I CRLF

        PAGE
/////   Critical point: This page delimits field 0 overlays.
/       All field 1 subroutines in command table must be in
/       the following page.

        CRITICAL=.

NOPSUB, 0
        JMP I NOPSUB

EXSUB,  0
        TAD (-5
        TAD PTR
        DCA I (DEPN
        JMP I EXSUB

EGSUB,  0
        TAD I (DEPN
        DCA PTR
        ISZ DELIM
        JMP I (GO

/ SETLPT, SETPTP, SETCRT, and SETTY must be in this order.

SETLPT, 0
        TAD SETLPT
        JMS SETXXX
SETPTP, 0
        TAD SETPTP
        JMS SETXXX
SETTV,  0
        TAD SETTV
        JMS SETXXX
SETTTY, 0
        TAD SETTTY
        JMS SETXXX
SETXXX, 0
        DCA SETDEV
        TAD SETXXX
        TAD (TTYDEV-SETTTY-3
        DCA T
        JMP SETDEV+1

SETDEV, 0
        TAD I T
        DCA DVNM1
        ISZ T
        TAD I T
        DCA DVNM2
        JMS SETOUT
        JMP I SETDEV

SETOUT, 0
        TAD I (FLAG
        RTR
        SZL CLA
        TAD (5
        TAD (7600
        DCA OLOC
        TAD I OLOC
        SZA CLA
        JMP I SETOUT    /HE'S SPECIFIED SOMTHING
        JMS I (200
        12              /INQUIRE
DVNM1,  0
DVNM2,  0
        0
        JMP I (CCER2    /NO SUCH DEVICE
        TAD DVNM2
        DCA I OLOC
        TAD I (FLAG
        RTR
        SNL CLA
        JMP I SETOUT
        JMS I (NMOVE
OLOC,   0
        JMP I SETOUT

///     PROCESS SWITCH/EXTENSION VECTOR

EXTSUB, SUBR
        SNA
        JMP I EXTSUB
        DCA T
        TAD I T
        DCA COMSUB
        ISZ T
        JMS I COMSUB
        JMP I EXTSUB

///     TRANSFER COM?? VALUES.  AC CONTAINS PTR.

COMSUB, SUBR
        TAD I T
        DCA SETEXT
        ISZ T
        TAD I T
        DCA DEFILE
        JMP I COMSUB

UNKN,   0
        TAD SETEXT
        SZA
        TAD I (TN       /SWITCH REQUEST
        SZA CLA
        JMP I (CCERA    /CAN'T HAVE 2ND DEFAULT EXTENSION
        TAD I (TN
        DCA SETEXT      /SET DEFAULT EXTENSION
        TAD DEFALT      /MAYBE IT'S IN COMMAND'S SEARCH LIST
        DCA DEF
        TAD SETEXT
        JMS I (EXTLUK
        SNA CLA         /DID WE FIND IT?
        JMP I (CDER4    /NO
        ISZ DEF         /YES
        TAD I DEF
        JMP EXTSUB+1    /UNKN IS CALLED ONLY VIA EXTSUB

DEFILE, 0       /FILE DEFINED BY EXTENSION.
SETEXT, 0       /EXT WHICH HAS BEEN SET BY A CCL SWITCH

SWCOMP, SUBR
        TAD I T
        DCA SWCOM1
        IAC RAL         / Test that -LS, -MP is legal.
        JMS I (SWTCHK
        JMS I (NMOVE
SWCOM1, 0
        JMP I SWCOMP

/ Print "Unknown command" message.
UNKNOWN,
IFDEF   CM69 <
        SUBR
        JMS I (PRMESG
        OOPS
        >/*CM69

        PAGE
