
      HED SYSTEM CONSOLE DRIVER 
* THE SYSTEM CONSOLE DRIVER CONTROLS ALL TRANSMISSION OF DATA BE- 
* TWEEN THE SYSTEM CONSOLE (ASR-35) AND THE SYSTEM. IT HANDLES ALL
* * IO FOR THE DEVICE AND PROVIDES FOR COMMUNICATION OF MESSAGES TO 
* THE SYSTEM, THE FOLLOWING VARIABLES ARE SIGNIFICANT:
* 
* T35F1: =0 DURING INPUT, -1 DURING OUTPUT. 
* T35F2: NORMALLY 0, IT IS SET TO -1 WHEN A COMPLETE MESSAGE HAS
*        BEEN RECEIVED. UNTIL IT IS CLEARED BY THE SYSTEM, ALL FUR- 
*        THER INPUT IS INHIBITED. 
* T35F3: NORMALLY 0, IT IS SET TO -1 WHEN A COMPLETE MESSAGE HAS
*        BEEN RECEIVED.  UNTIL IT IS CLEARED BY THE OUTPUT
*        INITIALIZATION SECTION OF THIS DRIVER, LOG AND MESSAGE 
*        ENTRIES ARE HELD OFF.
* TOG:   NOT USED DURING INPUT. DURING OUTPUT, BIT 0 = 0 IF NEXT
*        CHARACTER IS ON LEFT, 1 IF ON RIGHT. 
* TADR:  NOT USED DURING INPUT. DURING OUTPUT, TADR(14:0) POINTS TO 
*        THE WORD FROM WHICH THE NEXT CHARACTER WILL BE TAKEN.
*        BIT 15=1 FOR PUNCH & PRINT, 0 FOR PRINT ONLY.
* TCNT:  DURING INPUT, TCNT=# OF CHARS IN SO FAR. DURING OUTPUT,
*        TCNT(14:0)=# OF CHARS REMAINING TO BE OUTPUT, BIT 15=0 
*        IF A CRLF IS TO BE APPENDED, 1 IF NOT. 
* TBITS: CONTAINS CURRENT CONTROL BITS. 
*         120000 => PRINT 
*         130000 => PUNCH AND PRINT 
*         160000 => INPUT 
* TTA,TTB,TTE: USED TO SAVE THE VALUES OF A,B,E REGISTERS DURING
*        INTERRUPTS.
* 
* CALLING SEQUENCE: 
*     JSB TTY35,I  A=# OF CHARS (BIT 15=0 FOR CRLF, 1 FOR NONE) 
*                  B=BUFFER ADDRESS (BIT 15=1 FOR PUNCHING) 
* 
* INPUT MESSAGES ARE STORED IN THE 72 CHARACTER BUFFER T35BF. 
* 
      SPC 2 
?TT35 NOP           ENTRY POINT FOR OUTPUT. 
      CLF 0         INHIBIT INTERRUPT.
      STA TCNT      SET UP INITIAL PARAMETERS.
      STB TADR
      CCA           SET FLAG TO SAY 
      STA T35F1      OUTPUT.
      LDA ?TT35     COPY RETURN ADDRESS INTO THAT OF
      STA ?TT2       INTERRUPT SECTION. 
      CLA           SET TOG TO SAY LEFT HAND CHAR.
      STA TOG 
      STA T35F3 
* 
* TEST FOR PENDING INPUT. IF THERE IS ANY, EXIT IMMEDIATELY AND LET 
* THE INTERRUPT TRIGGER THE FIRST OUTPUT CHARACTER. 
* 
      LIA ?SC 
      SSA,RSS 
      JMP TT18      NONE PENDING--GO OUTPUT 1ST CHAR. 
      STF 0 
      JMP ?TT35,I 
* 
* INTERRUPT SECTION 
* 
?TT2  NOP 
      STA TTA       SAVE REGISTERS. 
      STB TTB 
      ERA 
      STA TTE 
      LDA T35F1     TEST FLAG TO DETERMINE IF 
      SZA,RSS        INPUT OR OUTPUT. 
      JMP TT17      INPUT 
      LIA ?SC       LOAD BACK LINE STATUS DURING OUTPUT 
      LDB T35ST     GET CONSOLE STATUS
      CPB %OUTW     IF OUTPUT WAIT
      LDB T35PR       USE PRIORITY
      CMB,INB 
      ADB .+%SYNT-.+1+ROS-COM2
      SSB,RSS       SKIP IF ABORT NOT ALLOWED 
      CPA B377      CHECK FOR A KEY STRUCK
      JMP TT18      NO INPUT, CONTINUE ON 
      CLA 
      STA T35F2     CLEAR CONTINUEING OUTPUT FLAG 
      STA T35ST     SET CONSOLE STATUS TO IDLE
* 
TT18  LDA TCNT       GET # OF CHARS LEFT. 
      RAL,CLE,ERA   COPY CRLF BIT INTO E. 
      SZA           ANY CHARS LEFT? 
      JMP TT5       YES--GO OUTPUT NEXT ONE.
      SEZ           NO--WANT CRLF?
      JMP TT6       NO--GO RESET FOR INPUT. 
      STA TOG       SET UP OUTPUT OF CRLF.
      LDA .+3       3 CHARS WITH
      IOR BIT15      NO CRLF FOLLOWING. 
      STA TCNT
      LDA TADR      KEEP PRINT/PUNCH BIT. 
      AND BIT15 
      IOR TTXCP 
      STA TADR
      JMP TT18
* 
* END OF OUTPUT--RESET FOR INPUT. 
* 
TT6   STA TCNT      SET COUNTER TO SAY NO CHARS IN. 
      STA T35F1     SET FLAG TO SAY INPUT.
      LDA B160K     GET CONTROL BITS FOR INPUT. 
      STA TBITS     SAVE. 
TT8   OTA ?SC       OUTPUT TO CONSOLE.
TT10  LDA TTE       RESTORE REGISTERS.
      ELA 
      LDA TTA 
      LDB TTB 
      STC ?SC,C     ENABLE DEVICE.
      STF 0         ENABLE INTERRUPT. 
      JMP ?TT2,I    EXIT. 
* 
* OUTPUT NEXT CHARACTER 
* 
TT5   CCA           DECREMENT 
      ADA TCNT       COUNTER. 
      STA TCNT
      LDB TADR      GET POINTER TO OUTPUT BUFFER. 
      LDA B120K     GET BITS FOR PRINT ONLY.
      RBL,CLE,SLB,ERB    TEST & CLEAR BIT 15 OF B.
      LDA B130K     GET PRINT/PUNCH BITS. 
      STA TBITS     SAVE CONTROL BITS.
      OTA ?SC       OUTPUT TO DEVICE. 
      LDA 1,I       GET WORD CONTAINING CHARACTER.
      LDB TOG       GET LEFT/RIGHT TOGGLE.
      SLB           IF RIGHT CHARACTER, 
      ISZ TADR       BUMP POINTER.
      SLB,RSS       IF LEFT CHARACTER,
      ALF,ALF        POSITION ON RIGHT. 
      ISZ TOG       REVERSE TOGGLE SENSE. 
TT15  AND B177      KEEP BITS 6-0 AND 
      IOR B200       SET BIT 7. 
      JMP TT8       GO OUTPUT CHARACTER.
* 
* CHARACTER HAS BEEN INPUT. 
* 
TT17  LDA T35F2     IGNORE CHARACTER IF T35F2 IS SET
      MIA 1          OR SWITCH 0 IS SET.
      SLA 
      JMP TT10
      LIA ?SC       GET CHARACTER IN A. 
      AND B177
      CCB           PREPARE -1 IN B.
      CPA .+12B     IGNORE LF, RUBOUT, NULL, XOFF.
      JMP TT10
      CPA B177
      JMP TT10
      SZA 
      CPA .+23B 
      JMP TT10
* 
**  TEST FOR 'CONTROL X'
* 
      CPA .+30B 
      JMP TT11
* 
      CPA BKSPC     TEST FOR "_"
      JMP TT12
      CPA .+15B     TEST FOR CR.
      STB T35F2     SET COMMUNICATION FLAG. 
      CPA .+15B 
      STB T35F3 
* 
* NOW INSERT CHARACTER IN BUFFER. 
* 
      LDB TCNT      GET COUNT IN B. 
      CPB .72        DON'T IF BUFFER IS FULL
      JMP TT10
      CLE,ERB       MOVE LEFT/RIGHT BIT TO E, AND 
      ADB T35B1      COMPUTE ADDRESS OF DESTINATION.
      SEZ,RSS       LEFT/RIGHT TEST.
      ALF,SLA,ALF   LEFT. 
      IOR 1,I       RIGHT.
      ISZ TCNT      BUMP COUNTER. 
TT16  STA 1,I        STORE IN BUFFER. 
      JMP TT10      GO EXIT.
* 
* HANDLE BACKSPACE. 
* 
TT12  LDB TCNT      GET CHARACTER COUNT 
      SZB,RSS       IGNORE IF NO CHARS YET. 
      JMP TT10
      ADB .-1       GET NEW TCNT. 
      STB TCNT
      CLE,ERB       CLEAR RIGHT HALF OF NEW DESTIN- 
      ADB T35B1     ATION.
      LDA 1,I 
      AND HIMSK 
      JMP TT16
* 
**  HANDLE 'CONTROL X'
* 
TT11  STB T35F1     SET OUTPUT FLAG.
      CLA           SET TCNT FOR CRLF AFTER "\".
      STA TCNT
      STA TADR      SET FOR NO PUNCHING.
      LDA B120K     SET FOR PRINT ONLY. 
      STA TBITS 
      OTA ?SC 
      LDA RVRSL     GO OUTPUT "\" 
TTYED JMP TT15
TTXCP DEF *+1 
      OCT 011415    X-OFF CR
      OCT 005000    LF
      HED TELETYPE TABLES 
      SUP 
* THE TELETYPE TABLES CONTAIN IN CORE INFORMATION FOR SYSTEM USERS. 
* EACH OF THE 32 USERS HAS 1 TABLE, CONTAINING THE FOLLOWING
* ENTRIES:
* (?FLAG MUST BE FIRST, AND ?CLOC THROUGH ?PLEV MUST
*  BE CONTIGUOUS.)
      SPC 1 
?FLAG EQU 0 
      SPC 1 
*                   CONTAINS ALL BIT FLAGS FOR USER 
* 
*     TERR  = 0001       TAPE ERROR 
*     CFLAG = 0002       COMPILE MODE 
*     HFLAG = 0004       HELLO IS RUNNING 
*     TAPEF = 0010       USER IN TAPE MODE
*     UNABT = 0020       UNABLE TO ABORT
*     OUTWT = 0040       OUTPUT BUFFER FULL 
*     COM14 = 0100       I/O PROCESSOR COMMUNICATION
*     ABTRY = 0200       ABORT ATTEMPT
*     DFCHK = 0400       DIRTY FILES CHECK
*     CHNFG = 1000       CHAIN RUNNING
*     PUALT = 2000       PROGRAM UNALTERED
*     MBUST = 4000       MBUSY POSITIVE 
*     PBFLG =10000       ABORT CAPABILITY DISABLED
*     CBFLG =20000       "BREAK" COMMAND GIVEN
* 
* 
      SPC 1 
?TNUM EQU ?FLAG+1 
      SPC 1 
*                   TELETYPE # IN BITS 12-8.
      SPC 1 
?DISC EQU ?TNUM+1 
      SPC 1 
*                   DISC ADDRESS OF THIS USER'S SWAP AREA 
      SPC 1 
?PROG EQU ?DISC+2 
      SPC 1 
*                   POINTS TO LAST USED WORD OF CORE PROGRAM. 
      SPC 1 
?ID   EQU ?PROG+1 
      SPC 1 
*                   USER ID.
      SPC 1 
?NAME EQU ?ID+1 
      SPC 1 
*                   8 CHAR PROGRAM NAME 
      SPC 1 
?TIME EQU ?NAME+3 
      SPC 1 
*                   STARTING TIME 
      SPC 1 
?CLOC EQU ?TIME+2 
      SPC 1 
*                   USER'S TIMEOUT CLOCK. 
      SPC 1 
?RSTR EQU ?CLOC+1 
      SPC 1 
*                   RESTART ADDRESS FOR SUSPENDED PROGRAMS. 
      SPC 1 
?STAT EQU ?RSTR+1 
      SPC 1 
*                   USER STATUS--WHEN ON Q INDICATED PROGRAM TYPE;
*                   WHEN NOT ON Q INDICATED REASON WHY. 
      SPC 1 
?LINK EQU ?STAT+1 
      SPC 1 
*                   POINTS TO LINK POSITION OF NEXT ENTRY ON QUEUE. 
      SPC 1 
?PLEV EQU ?LINK+1 
      SPC 1 
*                   FOR PROGRAMS ON Q, CONTAINS PRIORITY LEVEL. FOR 
*                   SUSPENDED PROGRAMS CONTAINS PROGRAM TYPE. 
      SPC 1 
?RTIM EQU ?PLEV+1 
      SPC 1 
*                   RESPONSE TIME FOR ENTER STATEMENT 
* 
?TEMP EQU ?RTIM+1 
* 
*                   TEMPORARIES FOR LIBRARY ROUTINES
      SKP 
TTY00 OCT 0 
      OCT 0 
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY01 OCT 0 
      OCT 400 
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY02 OCT 0 
      OCT 1000
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY03 OCT 0 
      OCT 1400
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY04 OCT 0 
      OCT 2000
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY05 OCT 0 
      OCT 2400
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY06 OCT 0 
      OCT 3000
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY07 OCT 0 
      OCT 3400
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY08 OCT 0 
      OCT 4000
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY09 OCT 0 
      OCT 4400
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY10 OCT 0 
      OCT 5000
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY11 OCT 0 
      OCT 5400
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY12 OCT 0 
      OCT 6000
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY13 OCT 0 
      OCT 6400
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY14 OCT 0 
      OCT 7000
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY15 OCT 0 
      OCT 7400
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY16 OCT 0 
      OCT 10000 
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY17 OCT 0 
      OCT 10400 
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY18 OCT 0 
      OCT 11000 
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY19 OCT 0 
      OCT 11400 
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY20 OCT 0 
      OCT 12000 
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY21 OCT 0 
      OCT 12400 
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY22 OCT 0 
      OCT 13000 
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY23 OCT 0 
      OCT 13400 
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY24 OCT 0 
      OCT 14000 
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY25 OCT 0 
      OCT 14400 
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY26 OCT 0 
      OCT 15000 
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY27 OCT 0 
      OCT 15400 
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY28 OCT 0 
      OCT 16000 
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY29 OCT 0 
      OCT 16400 
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY30 OCT 0 
      OCT 17000 
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
* 
TTY31 OCT 0 
      OCT 17400 
      OCT 0,0,0,0,0,0,0,0,0,0,0,0,0,0 
      OCT 0,0,0,0 
TTY32 EQU * 
      SPC 1 
* THE QUEUE ALWAYS CONTAINS AT LEAST ONE ENTRY, A DUMMY ENTRY. IT 
* IS POINTED TO BY THE LAST ACTUAL ELEMENT, AND POINTS TO THE FIRST.
* WHEN THE QUEUE IS OTHERWISE EMPTY, THE DUMMY LINK POINTS TO 
* ITSELF. 
      HED SWAP TRACK ERROR USER ZAPPER
* 
**
***      JETTISON PORT
**
* 
*     THIS ROUTINE IS CALLED WHEN A DISC TRANSFER TO OR FROM A
*     USER'S SWAP TRACK HAS FAILED.  THE ROUTINE SETS THE USER'S
*     PORT TO AN UNAVAILABLE STATUS AND CLEARS HIS FUSS TABLE.
*     ENTER WITH TTY TABLE ADDRESS IN B.
      SPC 2 
JETPT NOP 
      LDB MLINK+1   TAKE THIS 
      STB JETT1       USER OFF
      JSB JDEQU,I       THE QUEUE 
      LDB JETT1 
      ADB .+?STAT-?LINK  => STATUS WORD 
      LDA %PUN      SET PORT TO 
      STA B,I         UNAVAILABLE 
      ADB .+?ID-?STAT 
      CLA 
      STA MAIN      SAY NOBODY IN CORE
      STA B,I       CLEAR ID
      ADB .+?FLAG-?ID 
      STA B,I       CLEAR FLAGS WORD
      LDA M2000     READ IN 
      STA MWORD       THE FUSS TABLE
      LDA FUSS
      LDB LIBDI 
      JSB DISCZ,I 
      JSB SICK      IT'S STUCK ON THE DISC: GIVE UP 
      LDB JETT1     GET TABLE POINTER AGAIN 
      ADB .+?TNUM-?LINK 
      LDA B,I       GET THE PORT NUMBER 
      ALF,ALF 
      STA JETT1     SAVE IT 
      ALF,ALS         TIMES 32
      ADA LIBD
      STA JETT2 
      CLA           ZERO OUT
      LDB M32         THIS CLOD'S PART
      STA JETT2,I       OF THE FUSS 
      ISZ JETT2           TABLE 
      INB,SZB 
      JMP *-3 
      LDA FUSS      WRITE THE FUSS
      LDB LIBD        TABLE BACK TO 
      JSB DISCZ,I       THE DISC
      JSB SICK      DARN, IT'S STUCK IN CORE.  CROAK
      LDA JETT1     GET PORT NUMBER 
      JSB TCRIR       AND GO INFORM VICTIM
* 
*     ALSO INFORM THE SYSTEM OPERATOR WHAT WE'VE DONE.
* 
      CLF 0 
      JSB GMQBP,I   GO GET POINTER TO MESSAGE Q 
      JMP JSCH1,I   NO ROOM, SORRY
      STA JETT2     SAVE POINTER TO AVAILABLE BUFFER
      LDA JETT1     GET PORT NUMBER 
      CLB 
      DIV .+10      CONVERT 
      ALF,ALF         IT
      ADA B             TO
      ADA ASC00           ASCII 
      STA JETNO     INSERT IT INTO THE MESSAGE
      LDA JETMS     GET ADDRESS OF
      STA JETT1       STUFF TO BE MOVED 
      LDB .-16      MOVE
JET1  LDA JETT1,I     IT
      STA JETT2,I       INTO
      ISZ JETT1           THE 
      ISZ JETT2             MESSAGE 
      INB,SZB                 QUEUE 
      JMP JET1                  BUFFER
      JMP JSCH1,I   DONE, RETURN TO SCHEDULAR 
      SPC 2 
JSCH1 DEF SCH1
JDEQU DEF DEQUE 
JETT1 BSS 1 
JETT2 BSS 1 
JETMS DEF *+1 
      DEC 30
      OCT 6412      CR LF 
      ASC 3,PORT #
JETNO BSS 1 
      ASC 9, MADE UNAVAILABLE.
      OCT 6412      CR LF 
