         SYSTEM   SIG7
**************
*  CONTENTS  *
**************
*
*        PROGRAM SUMMARY
*        ASSEMBLY ALTERNATIVES
*        EQUS
*        VARIABLE DATA
*        CONSTANTS
*        FPT
*        MESSAGES
*        PATCH AREA
*        BREAK CONTROL
*        INITIALIZATION
*        MAIN COMMAND LOOP
*        BUILD COMMAND
*        PRINT COMMAND
*        END COMMAND
*        FINALIZATION
*        SUBROUTINES
         PAGE
*********************
*  PROGRAM SUMMARY  *
*********************
*
*FUNCTION*****
*
*    THE FUNCTION OF THE RATES SUBSYSTEM IS TO CREATE AND MAINTAIN THE
*    RATE FILE.  THE RATE FILE CONTAINS THE 8 CHARGE RATE STRUCTURES
*    WHICH SPECIFY HOW MANY CHARGE UNITS A USER WILL BE CHARGED FOR EACH
*    UNIT OF EACH TYPE OF SERVICE.  THE VARIOUS SERVICES ARE LISTED
*    UNDER P1-P8 IN THE MESSAGES SECTION.
*
*    LOGOFF USES THE RATE FILE TO CALCULATE THE NUMBER OF CHARGE UNITS
*    CHARGED FOR THE BATCH JOB OR ON-LINE SESSION JUST COMPLETED.
*    BATCH JOBS ARE CHARGED ACCORDING TO RATE STRUCTURE 0.
*    ON-LINE JOBS ARE CHARGED ACCORDING TO THE USERS LOGIN FILE (USERS).
*    THE LOGIN FILE IS MAINTAINED BY SUPER.
         PAGE
*COMMAND SUMMARY*****
*
*     STANDARD FORMAT    RESULT
*
*  BUILD N               THE NTH CHARGE RATE STRUCTURE IS MODIFIED.
*    WHERE N IS A DIGIT  EACH ITEM OF THE STRUCTURE IS PROMPTED FOR.
*    FROM 0-7            IF ONLY A CR IS GIVEN THE VALUE REMAINS
*                        UNCHANGED.
*
*  PRINT  N              PRINTS THE NTH CHARGE RATE STRUCTURE.
*
*  END                   CAUSES THE CHANGES FROM ANY BUILD COMMANDS
*                        TO BE WRITTEN TO THE FILE.  THEN, RETURNS
*                        TO TEL.
         PAGE
*EXAMPLE OF USE*****
*
*        UTS AT YOUR SERVICE
*        ON AT 11:12 MAY 09, '70
*        LOGON PLEASE:    :SYS,LBE
*                                   AND THE ACCOUNT :SYS.  ONLY FROM
*                                   THIS NAME & ACCOUNT CAN THE RATES
*                                   SUBSYSTEM BE ACCESSED.
*
*         RATES                     THE USER CALLS THE RATES SUBSYSTEM.
*                                   (IMAGINE A BANG PROMPT BEFORE THE
*                                   WORD RATES.)
*
*        RATES HERE                 RATES IDENTIFIES ITSELF.
*
*        -BUILD 2                   RATES PROMPTS FOR A COMMAND WITH A -
*                                   THE USER ASKS TO MODIFY CHARGE RATE
*                                   STRUCTURE NUMBER 2.
*        CPU TIME =10                        RATES PROMPTS THE USER FOR
*        CPU TIME * CORE SIZE =1             THE CHARGE UNITS PER UNIT
*        TERMINAL INTERACTIONS =1500         FOR EACH SERVICE,
*        I/O CALS =0
*        CONSOLE MINUTES =                   AND THE USER TYPES IN A
*        TAPES AND PACKS MOUNTED =           NUMBER OR A CARRIAGE RETURN
*        PAGE - DATE STORAGE=15000           FOR EACH.
*        PERIPHERAL I/O CARDS+PAGES =2500
*                                            A CARRIAGE RETURN BY ITSELF
*                                            INDICATES THE VALUE SHOULD
*                                            NOT BE CHANGED.
         PAGE
*        -PRINT 2                            THE USER ASKS TO PRINT
*                                            CHARGE RATE STRUCTURE 2,
*        CPU TIME =        10
*        CPU TIME * CORE SIZE =         1    AND RATES DOES SO.
*        TERMINAL INTERACTIONS =      1500
*        I/O CALS =         0
*        CONSOLE MINUTES =       200
*        TAPES AND PACKS MOUNTED =    100000
*        PAGE - DATE STORAGE =     15000
*        PERIPHERAL I/O CARDS+PAGES =      2000
*
*        -END                                THE USER ASKS TO RETURN TO
*                                            THE  TERMINAL EXECUTIVE.
*
*                                            THE MODIFICATIONS REQUESTED
*                                   ARE NOW WRITTEN TO THE :RATE
*                                            FILE.  THEY ARE ONLY
*                                            WRITTEN OUT ON EXITING.
*        RATES PROCESSING TERMINATED         RATES GIVES ITS NORMAL EXIT
*                                            MESSAGE.
*
*                                   (IMAGINE A BANG PROMPT HERE.)
*        !                                   THE TERMINAL EXECUTIVE
*                                            PROMPTS FOR A NEW COMMAND.
*             .
*             .
*             .
         PAGE
*OUTLINE FOR TESTING*****
*
*    1. USAGE
*           A. ACCESS FROM WRONG ACCOUNT.
*           B.                   NAME.
*           C.                   NAME&ACCOUNT.
*
*    2. STATUS OF FILE
*       2.1 FILE DOES NOT EXIST
*           A. CREATION MESSAGE (DOES IT COME OUT.)
*           B. DEFAULT VALUES (CHECK WITH PRINTS.)
*           C. BUILDS & PRINTS (CHECK WITH HEXDUMP.)
*       2.2 FILE EXISTS
*           A. PREVIOUS VALUES  (ARE THEY AS AFTER LAST CALL.)
*           B. BUILDS & PRINTS  (CHECK WITH HEXDUMP.)
*       2.3 FILE BUSY -- FOR LESS THAN LIMIT
*           A. DURING INITIALIZATION
*           B. DURING FINALIZATION
*       2.4 FILE BUSY -- FOR MORE THAN LIMIT
*           A. DURING INITIALIZATION
*           B. DURING FINALIZATION
*       2.5 OTHER
*           A. SIMULATE OTHER ERROR ON OPEN
*           B.                         READ
*           C.                         WRITE
*           D.                         CLOSE
*
         PAGE
*    3. SYNTAX ERRORS
*       3.1 ILLEGAL COMMAND
*           A. COMMAND NOT P,B OR E.
*           B. LAST CHARACTER OF P OR B NOT 0-7.
*       3.2 ILLEGAL NUMBER
*           A. TOO LONG
*           B. ILLEGAL CHARACTER
*           C. REPEATED ILLEGAL NUMBERS -- OVER LIMIT.
*           D. REPEATED ILLEGAL NUMBERS -- NOT OVER LIMIT.
*
*    4. NORMAL COMMANDS
*       4.1 PRINT
*           A. 0 VALUE
*           B. MEDIUM VALUES
*           C. LARGEST VALUE
*           D. 0 STRUCTURE
*           E. MIDDLE STRUCTURE
*           F. HIGHEST STRUCTURE = 7
*       4.2 BUILD
*           A. 0 VALUE
*           B. MEDIUM VALUES
*           C. LARGEST VALUE
*           D. CR
*           E. 0 STRUCTURE
*           F. MIDDLE STRUCTURE
*           G. HIGHEST STRUCTURE = 7
*       4.3 END
*           A. HEX DUMP AFTER (SEE 2.1&2.2)
*
         PAGE
*    5. BREAKS
*           A. IN INITIALIZATION
*           B. WHILE TYPING COMMAND
*           C. IMMEDIATELY AFTER P OR B.
*           D. IMMEDIATELY AFTER E
*           E. WHILE TYPING PROMPT WITHIN B.
*           F. IMMEDIATELY AFTER PROMPT WITHIN B.
*
*    6. CONTINUATION
*           A. CONTINUATION AFTER INTERRUPT WHILE TYPING COMMAND.
*           B. CONTINUATION AFTER INTERRUPT WHILE TYPING NUMBER.
*          C. CONTINUATION AFTER INTERRUPT WHILE PRINTING.
         PAGE
*SUBROUTINE SUMMARY*****
*SINPUT: INPUT TEXT.  RESULT IS IN INPUT.
*    REGISTERS CHANGED: R7,   R9
*SOUTPUT: OUTPUT TEXTC STRING+NL.  R8= ADDRESS.
*    REGISTERS CHANGED:       R9
*SOUTPUP: OUTPUT TEXTC STRING.  R8= ADDRESS.
*    REGISTERS CHANGED:       R9
*SOPEN: OPEN RATE FILE.
*    REGISTERS CHANGED:    R8,R9,R10,R11
*STOBIN: CONVERT DECIMAL TO BINARY.  INBUF =DECIMAL  R9= BINARY
*                                   R10= ERROR RETURN.
*    REGISTERS CHANGED: R7,R8,R9,    R11
*STODEC: CONVERT BINARY TO DECIMAL.  R9= BINARY.  NUMBER = DECIMAL.
*    REGISTERS CHANGED: R7,R8,R9,R10
         PAGE
***************************
*  ASSEMBLY ALTERNATIVES  *
***************************
FORUTS   EQU      1                 1 IF ASSEMBLED FOR UTS.
FORBTM   EQU      0                 1 IF ASSEMBLED FOR BTM.
         DEF      BBREAK
         DEF      ISTART
         REF      M:EI              DCB FOR :RATE FILE I/O
         DO1      FORBTM
         REF      M:SI              DCB FOR TERMINAL INPUT.
         DO1      FORBTM
         REF      M:SO              DCB FOR TERMINAL OUTPUT.
         DO1      FORUTS
         REF      M:UC              DCB FOR TERMINAL I/O ON UTS.
         DO1      FORUTS
M:SI     EQU      M:UC
         DO1      FORUTS
M:SO     EQU      M:UC
         DO1      FORUTS
         REF      J:JIT             START OF USERS JOB INFO TABLE.
         DO1      FORUTS
         REF      JACCN             DISPLACEMENT OF USERS ACCOUNT IN JIT
         DO1      FORUTS
         REF      JUNAME            DISPLACEMENT OF USERS NAME IN JIT.
TRIES    EQU      4                 TRIES IF FILE BUSY.
RATEMAX  EQU      7                 THERE ARE 0-7 CHARGE RATES.
ITEMMAX  EQU      8                 THERE ARE 8 ITEMS IN EACH
*                                     CHARGE RATE.
ERRMAX   EQU      2                 NO. ERRORS FOR ONE BUILD NUMBER
         PAGE
**********
*  EQUS  *
**********
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
R8       EQU      8
R9       EQU      9
R10      EQU      10
R11      EQU      11
R12      EQU      12
R13      EQU      13
R14      EQU      14
R15      EQU      15
         PAGE
*******************
*  VARIABLE DATA  *
*******************
         DO1      FORUTS
RATEVAR  CSECT    0                 CONTROL SECTION FOR VARIABLE DATA.
*BUFFER FOR RATE FILE AND INITIAL VALUES WHEN FIRST CREATED.
RATE     EQU      %                 :RATE FILE
         DATA     8,16,24,32,40,48,56,64  POINTERS TO 0-7 ENTRIES.
RATEBAS  EQU      %                 START OF 0TH ENTRY
         DATA     6,1,0,1000,0,100000,10000,2000                0
         DATA     6,1,1000,1000,200,100000,10000,2000           1
         DATA     6,1,1000,1000,200,100000,10000,2000           2
         DATA     6,1,1000,1000,200,100000,10000,2000           3
         DATA     6,1,1000,1000,200,100000,10000,2000           4
         DATA     6,1,1000,1000,200,100000,10000,2000           5
         DATA     6,1,1000,1000,200,100000,10000,2000           6
         DATA     6,1,1000,1000,200,100000,10000,2000           7
*INBUF BUFFER FOR ALL TERMINAL INPUT.
INBUF    EQU      %
         DO1      20
         TEXT     '    '
NUMBER   RES      10                PLACE BUILD DECIMAL NUMBER.
TOOLATE  DATA     0                 1 IF BREAK SHOULD BE IGNORE.
         PAGE
***************
*  CONSTANTS  *
***************
         DO1      FORUTS
RATEFIX  CSECT    2                 CONTROL SECTION FOR FIXED DATA.
NL       DATA     X'15000000'       NEW LINE CHARACTER.
BLANK    TEXT     '        '
         DO1      FORBTM
J:JIT    EQU      %
         DO1      FORBTM
         TEXT     ':SYS    '
         DO1      FORBTM
         TEXT     'LBE     '
         DO1      FORBTM
JACCN    EQU      0
         DO1      FORBTM
JUNAME   EQU      2
         PAGE
**********
*  FPTS  *
**********
EQPROMPT EQU      %                 SET PROMPT TO = FPT (M:PC).
         GEN,8,16,8 X'2C',0,C'='
MIPROMPT EQU      %                 SET PROMPT TO - FPT (M:PC).
         GEN,8,16,8 X'2C',0,C'-'
SLEEP    EQU      %                 SLEEP FPT (M:WAIT)
         GEN,8,24 X'F',1              INTERVAL OF SLEEP IS 1 SECOND.
*                                   USED TO DISMISS PROGRAM WHILE
*                                   WAITING FOR THE FILE TO BECOME
*                                   NOT BUSY.
BREAK    EQU      %                 SET BREAKS FPT (M:INT).
         GEN,8,7,17 X'0E',0,BBREAK    BREAKS GOTO BBREAK.
INPUT    EQU      %                 READ FPT (M:READ) FOR TERMINAL.
         GEN,8,7,17 X'10',0,M:SI
         DATA     X'34000000'
         DATA     INBUF             BUFFER ADDRESS IS INPUT.     3
         DATA     80                BUFFER SIZE IS 80 BYTES.     4
         DATA     0
*
OUTPUT   EQU      %                 WRITE FPT (M:WRITE) FOR TERMINAL.
         GEN,8,7,17 X'11',0,M:SO
         DATA     X'34000000'
         GEN,1,14,17 1,0,R8         BUFFER ADDRESS IS IN R8.     3
         GEN,1,14,17 1,0,R9         BUFFER SIZE IS IN R9.        4
         DATA     1                 DISPLACEMENT IS 1.           6
LINE     EQU      %                 WRITE FPT (M:WRITE) FOR NEW LINE.
         GEN,8,7,17 X'11',0,M:SO
         DATA     X'34000000'
         DATA     NL                BUFFER ADDRESS IS NL.        3
         DATA     1                 BUFFER SIZE IS 1.            4
         DATA     0                 DISPLACEMENT IS 0.           6
*
OPEN     EQU      %                 OPEN FPT (M:OPEN) FOR RATE FILE.
         GEN,8,7,17 X'14',0,M:EI
         DATA     X'F7400009'       ACCOUNT PRESENT & FILE TYPE.
         DATA     SOPENE1           ERROR ADDRESS.               1
         DATA     SOPENE1           ABNORMAL ADDRESS.            2
         DATA     RATE              BUFFER ADDRESS IS RATE.      3
         DATA     288               BUFFER SIZE IS 72 WORDS      4
         DATA     1                 ORGANIZATION IS CONSECUTIVE. 6
         DATA     1                 ACCESS IS SEQUENTIAL.        7
         GEN,1,14,17 1,0,R8         MODE IS IN R8.               8
*                                     2 IS OUTPUT.  4 IS UPDATE.
         DATA     2                 SAVE.                       10
         DATA,1   1,0,2,2
         TEXTC    ':RATE'
         DATA,1   2,1,2,2           FILE ACCOUNT IS: :SYS.
         DO1      FORUTS
         TEXT     ':SYS    '
         DO1      FORBTM
         TEXT     'C7308314'
         DATA     0,0,0
READ     EQU      %                 READ FPT (M:READ) FOR RATE FILE.
         GEN,8,7,17 X'10',0,M:EI
         GEN,4,28 X'C',0
         GEN,1,14,17 1,0,R9         ERROR ADDRESS IS IN R4.      1
         GEN,1,14,17 1,0,R9         ABNORMAL ADDRESS IS IN R9.   2
*
WRITE    EQU      %                 WRITE FPT (M:WRITE) FOR :RATE FILE.
         GEN,8,7,17 X'11',0,M:EI
         GEN,4,28 X'C',0
         GEN,1,14,17 1,0,R9         ERROR ADDRESS IS IN R9.      1
         GEN,1,14,17 1,0,R9         ABNORMAL ADDRESS IS IN R9.   2
*
CLOSE    EQU      %                 CLOSE FPT (M:CLOSE) FOR CLOSING
*                                   :RATE FILE
         GEN,8,7,17 X'15',0,M:EI
         GEN,1,14,17 1,0,0
         DATA     2                 SAVE.                        1
         PAGE
**************
*  MESSAGES  *
**************
M1       TEXTC    'RATES HERE'      INITIALIZATION
M2       TEXTC    'ILLEGAL COMMAND'     MAIN COMMAND LOOP.
M3       TEXTC    'LAST CHARACTER MUST BE 0-7'    BUILD OR PRINT.
M4       TEXTC    'ILLEGAL NUMBER'                BUILD
M4B      TEXTC    'RETYPE COMMAND'                          BUILD
M5       TEXTC    'UNEXPECTED I/O ERROR'     FINALIZATION
M6       TEXTC    'NO UPDATING TOOK PLACE'   FINALIZATION
M7       TEXTC    'RATES PROCESSING TERMINATED'   FINALIZATION
M8       TEXTC    'SORRY, YOU ARE NOT ALLOWED TO ACCESS THE :RATE FILE'
*                                            INITIALIZATION
M9       TEXTC    ':RATE FILE DID NOT EXIST, BUT HAS BEEN CREATED' SOPEN
PROMPTS  EQU      %-1                      POINTERS TO SIDINGS
         DATA     P1,P2,P3,P4,P5,P6,P7,P8
P1       TEXTC    'CPU TIME '
P2       TEXTC    'CPU TIME * CORE SIZE '
P3       TEXTC    'TERMINAL INTERACTIONS '
P4       TEXTC    'I/O CALS '
P5       TEXTC    'CONSOLE MINUTES '
P6       TEXTC    'TAPES AND PACKS MOUNTED '
P7       TEXTC    'PAGE - DATE STORAGE '
P8       TEXTC    'PERIPHERAL I/O CARDS+PAGES '
EQUAL    TEXTC    '='
         PAGE
****************
*  PATCH AREA  *
****************
         DO1      FORUTS
RATEPRO  CSECT    1                 CONTROL SECTION FOR PROGRAM.
*AREA FOR MAKING PATCHES OR GENMODS IF REQUIRED.
PATCH    EQU      %
         DO1      50
         DATA     0
         PAGE
*******************
*  BREAK CONTROL  *
*******************
BBREAK   EQU      %                 (BREAKS COME HERE.)
         MTW,0    TOOLATE           IF TOOLATE FLAG ON,  GOTO BBREAK1 AND
         BNEZ     BBREAK1             IGNORE BREAK.
         LW,R0    *R1               GET FIRST WORD OF PSD FROM TCB.
         AND,R0   =X'FFFE0000'      INSERT MLOOP AS ADDRESS OF
         OR,R0    =MLOOP              NEXT INSTRUCTION.
         STW,R0   *R1               PUT FIRST WORD OF PSD BACK.
BBREAK1  EQU      %
         CAL1,9   5                 EXIT FROM BREAK (M:TRNT) TO
*                                     NEXT COMMAND AT MLOOP
         PAGE
********************
*  INITIALIZATION  *
********************
*
ISTART   EQU      %
         CAL1,1   LINE              OUTPUT A NEW LINE CHARACTER.
         LI,R8    M1                OUTPUT 'RATES HERE'
         BAL,R15  SOUTPUT
         CAL1,1   LINE              OUTPUT A NEW LINE CHARACTER.
         LW,R2    J:JIT+JACCN       IF ACCOUNT IS NOT :SYS,
         CW,R2    L(C':SYS')          GOTO ERROR EXIT VIA ISTART2.
         BNE      ISTART2
         LW,R2    J:JIT+JACCN+1
         CW,R2    BLANK
         BNE      ISTART2
         LW,R2    J:JIT+JUNAME      IF NAME IS NOT LBE,
         CW,R2    L(C'LBE ')          GOTO ERROR EXIT VIA ISTART2
         BNE      ISTART2
         BAL,R15  SOPEN             OPEN RATE FILE.
         LI,R9    FEXITE            READ RATE FILE
         CAL1,1   READ                WITH ERRORS&ABNORMALS TO FEXITE.
         CAL1,1   CLOSE             CLOSE :RATE FILE.
         DO1      FORUTS
         CAL1,8   BREAK             SET BREAK CONTROL.
         B        MLOOP             GOTO COMMAND LOOP.
ISTART2  EQU      %
         LI,R8    M8                OUTPUT 'SORRY YOU ARE NOT ALLOWED
         BAL,R15  SOUTPUT                TO ACCESS THE :RATE FILE'.
         B        FEXIT             GOTO FEXIT.
         PAGE
***********************
*  MAIN COMMAND LOOP  *
***********************
MLOOP    EQU      %
         CAL1,1   LINE              OUTPUT A NEW LINE CHARACTER.
         DO1      FORUTS
         CAL1,1   MIPROMPT          SET PROMPT TO -.
         BAL,R15  SINPUT            READ NEXT COMMAND INTO INBUF
         LB,R8    INBUF             GET FIRST CHARACTER OF COMMAND..
         CI,R8    C'E'              IF E, GOTO CEND FOR END COMMAND.
         BE       CEND
         CI,R8    C'P'              IF P, GOTO CPRINT FOR PRINT COMMAND.
         BE       CPRINT
         CI,R8    C'B'              IF B, GOTO CBUILD FOR BUILD COMMAND.
         BE       CBUILD
         LI,R8    M2                OUTPUT 'ILLEGAL COMMAND'.
         BAL,R15  SOUTPUT
         B        MLOOP             GOTO MLOOP FOR NEXT COMMAND.
         PAGE
*******************
*  BUILD COMMAND  *
*******************
* R1= INDEX TO LAST CHARACTER OF COMMAND.
* R2= THE ITEM NUMBER OF THE ITEM BEING INPUT.   I
* R3= THE ADDRESS OF THE NEXT ITEM TO BE INPUT.  A
* R4= ERROR COUNT.
*******************
*  PRINT COMMAND  *
*******************
*  R1= INDEX TO LAST CHARACTER OF COMMAND.
*  R2= THE ITEM NUMBER OF THE ITEM BEING OUTPUT.       I
*  R3= THE ADDRESS OF THE NEXT ITEM TO BE OUTPUT.      A
CBUILD   EQU      %
CPRINT   EQU      %
         LW,R1    M:SI+4            CALCULATE INDEX TO LAST NON-
         SLS,R1   -17                 ACTIVATION CHARACTER.
         DO1      FORUTS
         AI,R1    -2
         DO1      FORBTM
         AI,R1    -1
         LB,R9    INBUF,R1
         CI,R9    C'0'              IF IT IS NOT 0-7, GOTO CBUILDE.
         BL       CBUILDE
         CI,R9    C'7'
         BG       CBUILDE
         AND,R9   =X'F'             A= BASE OF RATE TABLE +
         MI,R8    ITEMMAX             DISPLACEMENT.
         LI,R3    RATEBAS
         AW,R3    R9
         LI,R2    0                 I =0.
         CAL1,1   LINE              OUTPUT A NEW LINE CHARACTER.
         LB,R1    INBUF             IF PRINT COMMAND,
         CI,R1    C'P'                GOTO CPRINT1.
         BE       CPRINT1
         PAGE
CBUILD1  EQU      %
         CI,R2    ITEMMAX           IF I = ITEMMAX,
         BE       MLOOP               GOTO MLOOP FOR NEXT COMMAND.
         AI,R2    1                 I=I+1.
         LI,R4    0                 SET ERROR COUNT TO 0.
CBUILDZ  EQU      %
         LW,R8    PROMPTS,R2        OUTPUT THE ITH SIDING.
         BAL,R15  SOUTPUP
         DO1      FORUTS
         CAL1,1   EQPROMPT          SET PROMPT TO =.
         BAL,R15  SINPUT            INPUT THE NEXT NUMBER.
         LW,R8    M:SI+4            IF NO INPUT,
         SLS,R8   -17
         DO1      FORUTS
         AI,R8    -1
         BEZ      CBUILD2             GOTO CBUILD2 & DONT STORE NUMBER.
         LI,R10   CBUILDF           SET UP ERROR RETURN FOR CBUILDF.
         BAL,R15  STOBIN            CONVERT NUMBER TO BINARY.
         STW,R9   *R3               STORE NUMBER IN RATE TABLE.
CBUILD2  EQU      %
         AI,R3    1                 A=A+1.
         B        CBUILD1           GOTO CBUILD1 FOR NEXT ITEM.
         PAGE
CBUILDE  EQU      %
         LI,R8    M3                OUTPUT 'LAST CHARACTER MUST BE 0-7'.
         BAL,R15  SOUTPUT
         B        MLOOP             GOTO MLOOP FOR NEXT COMMAND.
*
CBUILDF  EQU      %
         LI,R8    M4                OUTPUT 'ILLEGAL NUMBER'
         BAL,R15  SOUTPUT
         CI,R4    ERRMAX            IF NO. ERRORS > MAXIMUM
         BE       CBUILDG             GOTO CBUILDG.
         AI,R4    1                 ERROR COUNT= ERROR COUNT+1.
         B        CBUILDZ           GOTO CBUILDZ FOR RETRY.
CBUILDG  EQU      %
         LI,R8    M4B               OUTPUT 'RETYPE COMMAND'.
         BAL,R15  SOUTPUT
         B        MLOOP             GOTO MLOOP FOR A NEW COMMAND.
         PAGE
CPRINT1  EQU      %
         CI,R2    ITEMMAX           IF I > ITEMMAX,
         BE       MLOOP               GOTO MLOOP FOR A NEW COMMAND.
         AI,R2    1                 I=I+1.
         LW,R8    PROMPTS,R2        OUTPUT THE SIDING FOR THE
         BAL,R15  SOUTPUP             NEXT ITEM.
         LI,R8    EQUAL             OUTPUT '='.
         BAL,R15  SOUTPUP
         LW,R9    *R3               GET THE NEXT NUMBER.
         BAL,R15  STODEC            CONVERT IT.
         LI,R8    NUMBER            OUTPUT IT.
         BAL,R15  SOUTPUT
         AI,R3    1                 A=A+1.
         B        CPRINT1           GOTO CPRINT1 FOR NEXT ITEM.
         PAGE
*****************
*  END COMMAND  *
*****************
*
CEND     EQU      %
         LI,R0    1                 SET TOO LATE FLAG ON.
         STW,R0   TOOLATE
         BAL,R15  SOPEN             OPEN :RATE FILE
         LI,R9    FEXITE            WRITE RATE FILE
         CAL1,1   WRITE               WITH ERRORS&ABNORMALS TO FEXITE.
         CAL1,1   CLOSE             CLOSE :RATE FILE
         B        FEXIT             GOTO FEXIT TO EXIT.
         PAGE
******************
*  FINALIZATION  *
******************
*
FEXIT    EQU      %
         LI,R8    M7                OUTPUT 'RATE PROCESSING TERMINATED'.
         BAL,R15  SOUTPUT
         CAL1,1   LINE              OUTPUT A NEW LINE CHARACTER.
         DO1 FORUTS
         CAL1,9   1                 EXIT TO TEL.
         DO1      FORBTM
         CAL3,6   0
FEXITE   EQU      %
         LI,R8    M5                OUTPUT 'UNEXPECTED I/O ERROR'.
         BAL,R15  SOUTPUT
         LI,R8    M6                OUTPUT 'NO UPDATING TOOK PLACE.'
         BAL,R15  SOUTPUT
         B        FEXIT             GOTO FEXIT.
         PAGE
******************
*  SUBROUTINES  *
******************
*
*
*SINPUT
*FUNCTION: INPUT TEXT FROM TERMINAL.
SINPUT   EQU      %
         CAL1,1   INPUT             INPUT TEXT.
         DO1      FORUTS
         B        *R15
         DO1      FORUTS
         GOTO     SINPUTE
         LW,R7    M:SI+4            INSERT CR FOR BTM.
         SLS,R7   -17
         LI,R9    X'15'
         STB,R9   INBUF,R7
         B        *R15              RETURN.
SINPUTE  BOUND    1
         PAGE
*
*
*SOUTPUT
*FUNCTION: OUTPUT TEXT TO TERMINAL + A NEW LINE.
*PARAMETERS: R8= BUFFER ADDRESS OF TEXTC STRING TO BE OUTPUT.
*REGISTERS USED: R9= BYTE SIZE OF STRING.
SOUTPUT  EQU      %
         LB,R9    *R8               GET BYTE SIZE OF TEXT.
         CAL1,1   OUTPUT            OUTPUT TEXT.
         CAL1,1   LINE              OUTPUT NEW LINE.
         B        *R15              RETURN.
         PAGE
*SOUTPUP
*FUNCTION: OUTPUT TEXT TO TERMINAL WITH NO ATTACHED NEW LINE.
*PARAMETERS: R8= BUFFER ADDRESS OF TEXTC STRING TO BE OUTPUT.
*REGISTERS USED: R9= BYTE SIZE OF STRING
SOUTPUP  EQU      %
         LB,R9    *R8               GET BYTE SIZE OF TEXT.
         CAL1,1   OUTPUT            OUTPUT TEXT.
         B        *R15              RETURN.
         PAGE
*
*
*SOPEN
*FUNCTION: TO OPEN RATE FILE.  TO CREATE IF DOESNT EXIT ON END COMMAND.
*REGISTERS: R8 =  MODE
*           R10 = ERROR CODE & SUBCODES
*           R11 =  TRIES IF BUSY
*
SOPEN    EQU      %
         LI,R8    4                 MODE = UPDATE.
         LI,R11   TRIES             TRIES IF BUSY = TRIES.
SOPEN1   EQU      %
         CAL1,1   OPEN              OPEN :RATE FILE
         B        *R15              RETURN.
SOPENE1  EQU      %                 (ERROR OR ABNORMAL)
         SLS,R10  -16               RIGHT JUSTIFY ERROR&SUBCODES.
         AND,R10  =X'FFFE'          ZERO FIRST BIT OF DCB ADDRESS.
         CI,R10   X'1402'           IF FILE IS NOT BUSY
*                                   (SUBCODE IS REALLY AN 01 IN FIRST
*                                    7 BITS OF BYTE.),
         BNE      SOPENE2             GOTO SOPENE2.
         DO1      FORUTS
         CAL1,8    SLEEP            DISMISS PROGRAM
         BDR,R11  SOPEN1            TRY TO OPEN AGAIN, UNLESS TO MANY
         B        FEXITE              TRIES, THEN GOTO FEXITE.
SOPENE2  EQU      %                 (NOT BUSY BUT SOME ERROR.)
         CI,R10   X'0300'           IF FILE EXISTS
         BNE      FEXITE              GOTO FEXITE.
         LI,R8    2                 OPEN FILE. IN OUTPUT MODE.
         CAL1,1   OPEN
         LI,R9    FEXITE            WRITE :RATE FILE
         CAL1,1   WRITE               WITH ERROR&ABNORMALS TO FEXITE.
         CAL1,1   CLOSE             CLOSE :RATE FILE.
         LI,R8    M9                OUTPUT ':RATE FILE DID NOT EXIST,
         LB,R9    M9                        BUT HAS BEEN CREATED'.
         CAL1,1   OUTPUT
         CAL1,1   LINE
         B        SOPEN             TRY OPENING AGAIN.
         PAGE
*STOBIN
*FUNCTION: TO CONVERT A DECIMAL NUMBER TO BINARY.
*PARAMETERS: INBUF= DECIMAL NUMBER FOLLOWED BY NEW LINE CHAR.
*RESULT: R9 = BINARY EQUIVALENT OF DECIMAL NUMBER.     NUMBER
*REGISTERS: R7 = INDEX TO NEXT BYTE.         I
*            R10 = ERROR RETURN.
*            R11 = NEXT DIGIT OF NUMBER.       DIGIT
STOBIN   EQU      %
         LW,R7    M:SI+4            GET LENGTH OF INPUT.
         SLS,R7   -17
         DO1      FORUTS
         AI,R7    -1                ADJUST FOR NEW LINE CHARACTER.
         CI,R7    8                 IF LENGTH >8
         BG       *R10                ERROR RETURN.
         LI,R7    0                 I=0.
         LI,R9    0                 NUMBER=0.
STOBIN1  EQU      %
         LB,R11   INBUF,R7          DIGIT=INBUF(I).
         CI,R11   X'15'             IF END OF NUMBER, RETURN.
         BE       *R15
         CI,R11   X'0D'
         BE       *R15
         CI,R11   C'0'              IF DIGIT IS NOT A DIGIT,
         BL       *R10                ERROR RETURN.
         CI,R11   C'9'
         BG       *R10
         AND,R11  =X'F'             DIGIT= DIGIT CONVERTED TO BINARY.
         MI,R8    10                NUMBER= NUMBER * 10.
         AW,R9    R11               NUMBER= NUMBER + DIGIT.
         AI,R7    1                 I=I+1.
         B        STOBIN1           GOTO STOBIN FOR NEXT DIGIT.
         PAGE
*
*
*STODEC
*FUNCTION: TO CONVERT A BINARY NUMBER TO DECIMAL.
*PARAMETERS: R9 = BINARY NUMBER.
*REGISTERS: R7 = INDEX TO BYTES IN NUMBER.                  I
*           R8 = REMAINDER AFTER DIVISION                   R
*RESULTS:   NUMBER = LENGTH BYTE FOLLOWED BY RIGHT JUSTIFIED
*              DECIMAL NUMBER.
STODEC   EQU      %
         LW,R10   BLANK             BLANK OUT NUMBER.
         STW,R10  NUMBER
         STW,R10  NUMBER+1
         STW,R10  NUMBER+2
         LI,R7    11                I=11.
STODEC1  EQU      %
         AI,R7    -1                I=I-1.
         LI,R8    0                 R=0.
         DW,R8    =10               N=N/10;R=REMAINDER(N/10).
         OR,R8    =X'F0'            R= R CONVERTED TO DECIMAL DIGIT.
         STB,R8   NUMBER,R7         NUMBER(I)=R.
         CI,R9    0                 IF N-NOT EQUAL 0,
         BNE      STODEC1             GOTO STODEC1 TO DIVIDE AGAIN.
STODEC2  EQU      %
         LI,R8    10                INSERT LENGTH OF NUMBER
         STB,R8   NUMBER              IN FIRST BYTE.
         B        *R15              RETURN.
         END      ISTART            START EXECUTION AT ISTART.

