      HED HELLO 
* THE HELLO COMMAND IS USED TO LOG A USER ON TO THE SYSTEM. IT
* PERFORMS THE FOLLOWING FUNCTIONS: 
*     1) IF A USER IS ALREADY ON, HE IS LOGGED OFF. 
*     2) READ USER ID AND PASSWORD, AND ENTER INTO TTY TABLE. 
*     3) READ TERMINAL SUBTYPE AND SET UP CARRIAGE RETURN AND 
*        LINEFEED DELAYS. 
      SPC 2 
      ORG LIBRA 
      LDA MLINK+1   SET HELID TO
      ADA .+?ID-?LINK POINT TO USER'S 
      STA HELID     ID. .
      ADA .+?TIME-?ID SET POINTER TO
      STA HELTP       STARTING TIME.
      ADA HELST     COMPUTE PORT NUMBER.
      CLB 
      STB HFLG      CLEAR COMMA FLAG
      DIV .+TTY01-TTY00 
      STA HELPT     SAVE IT.
      CPB HELID,I   TEST FOR USER IN CORE.
      JMP HEL7      GO INPUT IDT. 
* 
      LDA M128     INPUT FUSS TABLE 
      STA WORD
      LDA FUSS,I
      LDB LIBDI 
      JSB DISCL 
* qq
      LDA HELPT     COMPUTE LOCATION OF USER'S
      ALF,RAR           MULTIPLY BY 8            [X]
      ADA LIBD
      STA LTEMP 
* 
      CLA           ZERO OUT HIS SECTION. 
      LDB .-8                                    X] 
      STA LTEMP,I 
      ISZ LTEMP 
      INB,SZB 
      JMP *-3 
* qq
      LDA FUSS,I    WRITE BACK TO 
      LDB LIBD       DISC.
      JSB DISCL 
* 
      CLF 0 
      LDA PHR       SET UP TIMING 
      LDB MLINK+1 
      ADB .+?PHON-?LINK 
      STA B,I 
      ADB .+?TSTA-?PHON 
      LDA B,I 
      IOR LTBT
      STA B,I 
      STF 0 
HEL7  LDA HELID,I   IS ANYBODY
      SZA,RSS         LOGGED ON?
      JMP HEL1      NO
      STA ID        YES 
* 
* 
      DLD HELTP,I   GET STARTING TIME.
      CMA,INA       MAKE BOTH PARTS NEGATIVE. 
      CMB,INB 
      DST HELTM     SAVE. 
      DLD DATIM     GET CURRENT TIME. 
      ADA HELTM     COMPUTE DIFFERENCES:A=#OF HRS,
      CLE           B=# OF 100 MS UNITS,
      ADB HELTM+1    E INDICATES SIGN OF B. 
      STB HELTM+1   SAVE UNITS. 
      MPY D60       CHANGE HRS TO MINS. 
      STA HELTM 
      LDA HELTM+1   GET UNIT COUNT. IF E=0
      SEZ,RSS       THEN COUNT AS NEGATIVE. 
      CCB 
      DIV D600      CHANGE TO MINUTES.
      ADA HELTM     ADD PREVIOUS COMPUTATION +1 
      STA HELTM 
* qq
      LDA HELID,I   SET UP LOGOFF 
      IOR BIT15      ENTRY. 
      JSB HELOG 
* 
* 
* 
      JSB FIDT      FIND THE ID 
      ADB .+5       COMPUTE NEW TOTAL TIME. 
      CLE 
      LDA 1,I 
      ADA HELTM 
      SEZ           IF OVERFLOW, USE MAXIMUM. 
      CCA 
      STA 1,I 
* 
      LDA IDTRA,I 
      LDB LIBD
      JSB DISCL 
* 
      STA HELID,I   REMOVE USER'S ID FROM TABLE.
* 
* CONVERT ID
* 
HEL1  JSB GETID     TRANSLATE ID. 
      RSS 
      JMP GTFER     ERROR--NO COMMA 
      CPA .+54B ii
      RSS 
      JMP GTFER     ERROR--NO COMMA.
* 
*                                                                B] 
      JSB FIDT
      RSS 
      JMP HELF
* 
      LDA .-3       CHECK PASSWORD. 
      STA HELC
      STB HELP
HEL3  ISZ HELP      BUMP TO NEXT PASSWORD ENTRY.
      LDB HFLG      COMMA PREVIOUSLY
      SZB             ENCOUNTERED?
      JMP HEL3A     YES 
      JSB LCHAR     NO, GET 1ST CHARACTER 
      JMP HEL3A     CARRIAGE RETURN 
      CPA .+54B     COMMA?
      RSS 
      JMP HEL3B     NO
      STA HFLG      YES, SET FLAG 
HEL3A EQU * 
      CLA 
HEL3B EQU * *
      ALF,ALF       FIRST CHARACTER ON LEFT 
      STA HELGT 
      LDB HFLG      COMMA PREVIOUSLY
      SZB             ENCOUNTERED?
      JMP HEL3C     YES 
      JSB LCHAR     NO, GET 2ND CHARACTER 
      JMP HEL3C     CARRIAGE RETURN 
      CPA .+54B     COMMA?
      RSS 
      JMP HEL3D     NO
      STA HFLG      YES, SET FLAG 
HEL3C EQU * 
      CLA 
HEL3D EQU * 
      ADA HELGT     ADD FIRST CHARACTER 
      CPA HELP,I    DOES THIS PORTION OF
      RSS             THE PASSWORD COMPARE? 
      JMP HELF      NO - GO TO ERROR PRINT
      ISZ HELC      YES, BUMP CHARACTER COUNTER 
      JMP HEL3      GET NEXT CHARACTER PAIR 
* 
**    PASSWORD OK - PROCESS THE SUBTYPE 
* 
      LDB HFLG      COMMA PREVIOUSLY
      SZB             ENCOUNTERED?
      JMP HEL3E     YES 
      JSB LCHAR     NO, GET NEXT CHARACTER
      JMP HEL3F     'CR' - MUST BE SUBTYPE 0
      CPA .+54B     COMMA?
      RSS 
      JMP ILFER     NO - ERROR
HEL3E EQU * 
      JSB LCHAR 
      JMP ILFER     CARRIAGE RETURN - ERROR 
      ADA D65                                    [E]
      SSA,RSS       CHECK 
      JMP ILFER 
      ADA .+5         PARAMETER                  [E]
      SSA 
      JMP ILFER         RANGE 
      RSS 
HEL3F EQU * *s
      CLA 
      STA HTYPE     SAVE SUBTYPE
      LDB MLINK+1 
      ADB .+?TSTA-?LINK 
      ERA,ERA       E = 1 FOR SUBTYPES 2 AND 3   [E]
      LDA B,I       A = USER'S I/O STATUS 
      AND XOFNT     REMOVE X-OFF BIT             [E]
      SEZ           IF SUBTYPE 2 OR 3,           [E]
      IOR XOFBT       SET X-OFF BIT              [E]
      STA B,I       STORE NEW STATUS
      ADB .+?RPRM-?TSTA 
      LDA B,I       GET BAUD RATE 
      IOR BIT12       MAKE SURE ECHO
      STA B,I           IS TURNED ON, 
      AND B377            AND ADJUST FOR
      ADA M277              TABLE LOOK-UP 
      LDB BAUDT     B => LOOK-UP TABLE
HEL3G EQU * 
      ADA B,I 
      SSA,RSS       RIGHT RANGE?
      JMP HEL3H     YES 
      ADB .+6       NO, BUMP POINTER TO NEXT GROUP
      JMP HEL3G     TRY AGAIN 
HEL3H EQU * 
      INB 
      ADB HTYPE 
      LDA B,I       A = DELAY VALUES
      STA HTYPE 
      LDB MLINK+1 
      ADB .+?CDLY-?LINK 
      ALF,ALF 
      AND B377
      CMA,INA       NEGATE
      STA B,I       STORE 'CR' DELAY
      INB BE
      LDA HTYPE 
      AND B377
      CMA,INA       NEGATE
      STA B,I       STORE 'LF' DELAY
* qq
**    SUBTYPE OK - GET THE OVERLAY
* 
      LDA HLEN
      STA WORD
      LDB LIB       LOAD
      INB             OVERLAY 
      LDA 1,I I
      LDB #LIBI I)
      JMP HOVRL     GO LOAD OVERLAY 
      SPC 2 
* 
**    CARRIAGE RETURN - LINEFEED DELAY TABLE
* 
*             UPPER 8 BITS - CARRIAGE RETURN
*             LOWER 8 BITS - LINEFEED 
* 
      SPC 1 
*                      DELAY     SUBTYPE
      SPC 1 
BAUDT DEF *+1 
      OCT 75        =277-202
* *q
      OCT 400       0   * 
      OCT 0         1    *
      OCT 1400      2    **  DELAYS FOR 110 BAUD
      OCT 1         3    *
      OCT 11        4   * 
      SPC 1 
      OCT 43        =202-137
* 
      OCT 0         0   * 
      OCT 1000      1    *
      OCT 400       2    **  DELAYS FOR 150 BAUD
      OCT 3         3    *
      OCT 15        4   * 
      SPC 1 
      OCT 60        =137-57 
* 
      OCT 0         0   * 
      OCT 2000      1    *
      OCT 4400      2    **  DELAYS FOR 300 BAUD
      OCT 10        3    *
      OCT 34        4   * 
      SPC 2 
HELF  LDA .-12      PRINT ILL. ACCESS 
      LDB HELK
      JMP LIBER 
      SPC 2 
HOVRL EQU * 
      JSB DISCL     LOAD OVERLAY
      JMP LIBRA 
      SPC 2 
HELOG NOP           MAKE ENTRY IN LOG TABLE 
      LDB LOGCT     WAIT UNTIL
      CPB .+16        THERE IS ROOM 
      JMP *-2 
      LDB LOGP2     SET POINTER TO NEXT 
      INB             LOCATION IN LOG QUEUE 
      CPB LOGND 
      LDB LOGBG 
      CLF 0 
      STB LOGP2 
      STA LOGP2,I   ENTER ID
      LDA DATIM     GET DAY COUNT 
      CLB           GET HOURS OF TODAY
      DIV .+24
      LDA B 
      MPY D60       CONVERT TO MINUTES
      STA HELGT     SAVE
      LDA DATIM+1   GET UNIT COUNTER
      ADA D36K      ADJUST
      DIV D600      GET IN MINUTES
      ADA HELGT 
      ISZ LOGP2     PUT IN QUEUE
      ALF 
      IOR HELPT     MERGE IN PORT NUMBER
      STA LOGP2,I 
      ISZ LOGCT     BUMP COUNT
      STF 0 
      JMP HELOG,I   RETURN
      SPC 2 
HFLG  OCT 0 
HTYPE BSS 1 
M277  OCT 177501
HLEN ABS LIBRA-HOVRL
HELST ABS -TTY00-?TIME
HELRT DEF EXIT3 
HELPT EQU LTEMP+1 
HELID EQU LTEMP+6 
HELTP EQU LTEMP+7 
HELTM EQU LTEMP+8 
HELC  EQU LTEMP+10
HELP  EQU LTEMP+11
HELGT EQU LTEMP+12
HELM  ASC 3,HELLO 
$HEL  EQU * 
      HED HELLO OVERLAY 
* 
**   CHECK FOR ANY TIME LEFT
* 
      ORG LIBRA 
      ISZ HELP      COMPUTE 
      DLD HELP,I     ALLOWED TIME-TIME TO DATE. 
      CMA,CLE,INA 
      ADA 1 
      SEZ 
      JMP HELG      NO TIME LEFT. 
* 
      LDA ID        MAKE LOG ENTRY. 
      JSB HELOG 
      DLD DATIM      SET STARTING TIME AND ID 
      DST HELTP,I     INTO TABLE. 
      LDA ID        INSERT NEW ID AND CLEAR 
      CLB            NAME.
      DST HELID,I Iv
      LDA PBUFF     ALSO SCRATCH
      LDB MLINK+1 
      ADB .+?PROG-?LINK 
      STA 1,I 
      CLF 0 
      ADB .+?TSTA-?PROG 
      LDA B,I       REMOVE LOG
      AND LTNBT       TIMING BIT
      STA B,I 
      LDA A000      MOVE SETUP FOR
      STA LTEMP      $HELLO PROGRAM 
      LDA HELM        INTO LTEMP(0:3).
      STA LTEMP+1 
      DLD HELM+1
      DST LTEMP+2 2,
* 
      JSB DLOOK     SEARCH FOR PROGRAM IN LIBRARY.
      JMP HEL6      FOUND IT. 
* 
* qq
HEL4  CLF 0 
      ISZ LIB 
      STF 0 
      LDA .-6       OUTPUT READY MESSAGE
      LDB READY Y
      JMP LIBER 
HELG LDA .-14 
      LDB HELH
      CLF 0         MAKE SURE SWAPPER 
      ISZ LIB         KNOWS HELLO IS NOT
      STF 0             IN CORE 
      JMP LIBER 
* *q
* 
* 
* SET UP USER TO RUN $HELLO PROGRAM.
* qq
HEL6  LDB LTEMP+5   TEST FOR FILE 
      ADB .+2 
      LDA 1,I 
      SSA 
      JMP HEL4Li
* 
      ADB .+2 
      LDA 1,I       SAVE START-OF-
      STA LIBSP       PROGRAM POINTER 
      ADB .+2       GET PROGRAM DISC ADDRESS AND
      DLD 1,I        LENGTH.
      STA HELP      SAVE DISK ADDRESS.
      STB HELC      STORE LENGTH. 
      CMB,INB       COMPUTE FIRST 
      ADB LIBSP       UNUSED WORD 
      STB LIBPB 
      CMB,INB       TEST FOR OVERFLOW.
      ADB U4475 
      SSB 
      JMP HEL4
* 
      JSB RDPRG     READ IN FIXED AREA. 
      LDA HELC      READ IN $HELLO. 
      STA WORD
      LDA HELP
      LDB LIBSP     GET START OF PROGRAM POINTER
      ADB BIT15 
      JSB DISCL 
      JSB SEMIC 
      CLF 0         PLAY SAFE.
      LDB MLINK+1 
      ADB .+?MASK-?LINK 
      LDA B,I       SET USER'S MASK BIT 
      IOR HFLAG       IN HELLO BIT FLAG 
      STA HFLAG 
      ADB .+?STAT-?MASK 
      LDA %RUN      SET USER'S STATUS TO RUN
      STA B,I 
      ADB .+?TSTA-?STAT                          [E]
      LDA B,I       SET 'UNABLE TO               [E]
      IOR UNABT       ABORT' BIT                 [E]
      STA B,I                                    [E]
      ISZ TIMEF     SET FLAG FOR TIMING.
      LDB SPROG 
      CPB PBPTR     NULL PROGRAM
      JMP HELRT,I   YES 
      STB PRGCT 
      LDA .+40B B6
      STA BLANK 
      ISZ LIB       HELLO NOT IN CORE 
      STF 0         INTERRUPT BACK ON.
      JMP *+1,I 
      DEF CMP14 
* 
$$HEL EQU * 
      HED BYE 
* THE BYE COMMAND IS USED TO LOG A USER OFF. BYE MUST PERFORM THE 
* FOLLOWING FUNCTIONS:
*     1) DETERMINE AMOUNT OF CONSOLE TIME USED
*     2) UPDATE USER'S CLOCK IN ID-TABLE
*     3) SET FLAG FOR SYSTEM TO UNHOOK. 
*     4) OUTPUT TERMINATION MESSAGE 
      SPC 2 
      ORG LIBRA 
      LDB MLINK+1 
      ADB .-?LINK+?ID                            X] 
      LDA 1,I       GET ID
      SZA,RSS       IF ID=0, USER NEVER 
      JMP LLEND     LOGGED ON, SO EXIT
      STB BYEID     SAVE POINTER TO ID
      STA ID
      LDA M128     INPUT FUSS TABLE 
      STA WORD
      LDA FUSS,I
      LDB LIBDI 
      JSB DISCL 
* 
      LDA MLINK+1   COMPUTE USER'S PORT NO. 
      ADA BYESP 
      CLB 
      DIV .+TTY01-TTY00 
      STA BYEPT Tn
* 
      ALF,RAR 
      ADA LIBD
      STA LTEMP+1 
      LDA .-8      CLEAR USER'S FUSS             X] 
      STB LTEMP+1,I 
      ISZ LTEMP+1 
      INA,SZA 
      JMP *-3 
* 
      LDA FUSS,I    WRITE FUSS
      LDB LIBD       BACK TO DISC.
      JSB DISCL 
* *q
* 
      LDA MLINK+1 
      ADA .+?TIME-?LINK  SET POINTER TO START TIME. 
      DLD 0,I          GET STARTING TIME. 
      CMA,INA       SET BOTH PARTS NEGATIVE.
      CMB,INB 
      DST BYETM     SAVE
      DLD DATIM     NOW GET CURRENT TIME
      ADA BYETM     COMPUTE DIFFERENCES: A=# OF HRS,
      CLE           B=# OF 100 MS UNITS,
      ADB BYETM+1    E INDICATES SIGN OF B. 
      STB BYETM+1   SAVE UNITS. 
      MPY D60       CHANGE HRS TO MINS. 
      STA BYETM 
      LDA BYETM+1   GET UNIT COUNT. IF E=0
      SEZ,RSS       THEN COUNT AS NEGATIVE. 
      CCB 
      DIV D600      CHANGE TO MINUTES.
      ADA BYETM     ADD PREVIOUS COMPUTATION PLUS 
      STA BYETM 
* 
      LDA LOGCT     CHECK FOR ROOM IN LOG TABLE 
      CPA .+16
      JMP *-2 
      LDA LOGP2     SET LOGP2 TO NEXT LOCATION IN 
      INA            LOG TABLE. 
      CPA LOGND 
      LDA LOGBG 
      STA LOGP2 
      LDA BYEID,I   PLACE ID IN LOG TABLE AND 
      IOR BIT15      SAY LOGOFF.
      STA LOGP2,I 
      ISZ LOGP2 
      DLD DATIM     COMPUTE TIME OF DAY.
      STB BYETM+1   SAVE UNIT COUNTER.
      CLB           GET # OF HRS IN B BY MOD'ING
      DIV .+24       OFF THE DAY COUNT. 
      LDA 1 
      MPY D60       CONVERT TO MINS.
      STA BYET      SAVE THAT.
      LDA BYETM+1   GET UNIT COUNTER. 
      ADA D36K      ADJUST
      DIV D600       GET MINUTES. 
      ADA BYET      PACK TOGETHER AND PUT IN LOG
      ALF                                            [X]
      IOR BYEPT 
      STA LOGP2,I    TABLE. 
      ISZ LOGCT     BUMP COUNTER. 
      JSB FIDT
* 
      ADB .+5       COMPUTE NEW TOTAL TIME. 
      CLE 
      LDA 1,I 
      ADA BYETM 
      SEZ           IF OVERFLOW, USE MAXIMUM. 
      CCA 
      STA 1,I 
* qq
      LDA IDTRA,I   WRITE ID TRACK BACK OUT 
      LDB LIBD
      JSB DISC,I
* qq
      CLA           REMOVE USER'S ID
      STA BYEID,I    FROM TABLE 
* 
      LDA .+12B 
      JSB LOUT
* 
      LDA BYETM 
      CLB           OUTPUT # OF MINUTES.
      DIV .1000n
      STB BYETEp
      ADA .+60B 
      JSB LOUT      HUNDREDS
      LDA BYET
      CLB 
      DIV .+10
      STB BYET
      ADA .+60B 
      JSB LOUT      TENS
      LDA BYETE,
      ADA .+60B 
      JSB LOUT      UNITS.
* qq
      LDA .-25      OUTPUT THE REST OF
      LDB BYEM       THE MESSAGE. 
      JSB LTYPE 
      LDA .-20      DISCONNECT USER 
      LDB MLINK+1 
      ADB .+?PHON-?LINK 
      STA B,I 
      ADB .+?TSTA-?PHON 
      LDA B,I IH
      IOR LTBT
      AND RNNBT 
      STA B,I IA
      ADB .+?RPRM-?TSTA 
      LDA B,I       A = RECEIVE PARAM 
      IOR BIT12     MAKE SURE USER'S
      STA B,I         ECHO IS TURNED ON 
      JMP LLEND 
* 
BYEID EQU LTEMP 
BYETM EQU LTEMP+1 
BYET  EQU LTEMP+3 
BYEPT EQU LTEMP+4 
BYEM  DEF *+1 
      ASC 13, MINUTES OF TERMINAL TIME. 
BYESP ABS -TTY00-?LINK
$BYE  EQU * 
