         TITLE    'APLINP-B00,08/20/73,DWG702985'                               
         SYSTEM   SIG7F                                                         
         SYSTEM   BPM                                                           
*                                                                               
*   REF'S:                                                                      
         REF      BCONTOFF          DOES CONTINUE EXIT                          
         REF      B4CLOSE           DOES FORCED CLOSE                           
         REF      BLANKS            X'40404040'                                 
         REF      BREAKFLG          BREAK FLAG                                  
         REF      BSPFLAG           BACKSPACE VALIDITY FLAG                     
         REF      CALWROUT          APL WRITE OUTPUT RECORD                     
         REF      CS1               CODESTRING GENERATOR                        
         REF      CX                CODESTRING EXECUTION                        
         REF      DUMPLINP          DUMP IMAGE-PROBABLY AS PROMPT               
         REF      ENDIMAGE          END OF IMAGE IN USE                         
         REF      ERRORCHR          ERROR-EVAL INP PROMPT-CHARACTERS            
         REF      ERXEQ             ERROR RETURN FOR 'EXECUTE'          12-00010
         REF      FIHANDLR          FUNCTION INPUT HANDLER                      
         REF      HICOL                                                         
         REF      IMAGE             APL 'IMAGE' I/O BUFFER                      
         REF      INBUF             APL INPUT-OUTPUT BUFFER                     
         REF      INTRANS                                                       
         REF      MAXCOL            MAX COL POS FOR INPUT                       
         REF      MERGECOL          MERGE COLUMN                                
         REF      MODE              MODE FLAG                                   
         REF      OBSFLAG           OBSERVE FLAG.                               
         REF      ON%OFF            ON-OFF LINE FLAG                            
         REF      OUTSIZ            SIZE OF OUTPUT RECORD(5)                    
         REF      RDAPL             READ APL INPUT RECORD                       
         REF      RELEASER                                                      
         REF      RESQQUAD          RESUME QUOTE-QUAD PROCESSING.               
         REF      TABPNTR           TAB INDICATOR                               
         REF      TABVALS           TAB VALUES                                  
         REF      TERMTYPE          TERMINAL TYPE                               
         REF      WROUT             APL WRITE OUTPUT RECORD                     
         REF      WROUTWB           WRITE-WORD BOUND                            
         REF      RESXTEND,CMDERRH,EDUMPLIN                                     
         REF      IDBADCH,IDOPENQT,IDTRUNC                                      
*   DEF'S:                                                                      
         DEF      APLINP@           START OF PROCEDURE                          
         DEF     APLINP0           START OF CONTEXT                             
         DEF      APLINPUT                                                      
         DEF      BCX               BREF TO CX-CODESTRING EXEC.                 
         DEF      DWSIZIM           IMAGE DW SIZE                               
         DEF      EDITCK            EDIT CHECK COL. NO.                         
         DEF      INPDIR            DIRECT INPUT HANDLER                        
         DEF      INPEVAL                                                       
         DEF      INPF              INPUT FUNCTION LINE                         
         DEF      INPFAPND          INPUT FUN.LINE, APPEND.                     
         DEF      INP4MERG          INPUT LINE FOR MERGE                        
         DEF      INPLSCER          ENTRY TO INPUT FROM LINE-SCAN ERROR         
         DEF      INPQQUAD                                                      
         DEF      INPRET                                                        
         DEF      INPXEQ            'INPUT' FOR 'EXECUTE'               12-00012
         DEF      INPXTEND          INPUT LINE EXTENSION                        
         DEF      LETTERS           DW 'A','Z'                                  
         DEF      MNEMT1            MNEMONIC TABLE    1-CHAR                    
         DEF      MNEMT2            MNEMONIC TABLE    2-CHAR                    
         DEF      MNEMT3            MNEMONIC TABLE    3-CHAR                    
         DEF      OUTFLAG           O-U-T FLAG                                  
         DEF      OVHWTABL          OVERSTRIKE CHAR TABLE                       
         DEF      PRMTIMAG          PROMPT WITH CONTENTS OF IMAGE               
         DEF      QCNT              QUOTE COUNT                                 
         DEF      SAVE312           SAVE AREA FOR APLINPUT                      
         DEF      SQUEEZER          ENTRY TO APLINPUT-SQUEEZE  MNEM'S           
*   STANDARD EQU'S                                                              
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                                                            
NBIO     EQU      3                 NO. OF BLIND I/O CHANNELS+1                 
BLANK    EQU      X'40'                                                         
IDLE     EQU      X'16'                                                         
BYSIZIM  EQU      MAXCOL            HIGH END OF IMAGE TO BE BYTE-BLANKED        
DWSIZIM  EQU      17                NO OF DW'S IN IMAGE TO BE BLANKED           
         PAGE                                                                   
*                                                                               
*  MODULE DESCRIPTION:                                                          
*                                                                               
*        THIS MODULE INCLUDES THE INPUT ROUTINES AND PROCESSES FOR              
*        APL,EXCEPT APL FILE I/O AND WORKSPACE MANAGEMENT I/O                   
*                                                                               
*           INPUT OPERATIONS INCLUDED:BLIND INPUT HANDLER                       
*                                    :QUOTE-QUAD INPUT HANDLER                  
*                                    :EVALUATED INPUT HANDLER                   
*                                    :DIRECT INPUT HANDLER                      
*                                    :FUNCTION EDIT INPUT HANDLER               
*           THE COMMON INPUT ROUTINE, APLINPUT, IS USED BY ALL EXCEPT           
*               THE BLIND INPUT HANDLER                                         
*                                                                               
*           THE DIRECT INPUT HANDLER MAY ALSO BE CONSIDERED THE                 
*            DRIVER FOR APL-IT PERFORMS-VIA OTHER MODULES-NECESSARY             
*            MEMORY MANAGEMENT PROCESSES PRIOR TO CALLING FOR INPUT             
*                                                                               
*        THIS MODULE INTERFACES WITH:THE CODESTRING GENERATION MODULE,          
*                    THE MONITOR INTERFACE MODULE(APLUTSI),                     
*                    THE OUTPUT MODULE (APLOUT)                                 
*                    THE CODESTRING EXECUTION MODULE                            
*                    THE FUNCTION DEF & EDIT MODULE                             
*                    THE WORKSPACE MANAGEMENT MODULE                            
*                                                                               
         PAGE                                                                   
APLINP0  CSECT    0                                                             
*                                                                               
*  FLAGS AND TEMPS IN APLINP                                                    
*                                                                               
         BOUND    8                                                             
EDITCK   DATA     0,0               EDIT CHECK FLAG                     U12-0004
OUTFLAG  EQU      EDITCK+1          O-U-T FLAG                                  
QCNT     RES      1                 QUOTE COUNT                                 
SAVE312  RES      10                SAVE R3-R12 COMMON INPUT ROUTINE            
BCHAR    RES      1                 BAD CHAR FLAG                               
MNEMFLG  RES      1                 MNEMONIC '%' FLAG-INPUT ROUTINE             
INSWITCH DATA     INPREAL           INPUT FETCH SWITCH                          
         PAGE                                                                   
APLINP@  CSECT    1                                                             
*                                                                               
*  INPUT MNEMONIC TABLES                                                        
*    1.  MNEMT3 - TABLE OF 3 CHARACTER MNEMONICS-4TH CHARACTER IS               
*                 THE CHARACTER REPRESENTED.                                    
*                                                                               
*                 TABLE IS ORDERED. INSERTIONS MUST BE IN ORDER                 
*        MNEMT3SZ IS TABLE SIZE                                                 
*                                                                               
*    2.  MNEMT2 - HALFWORD TABLE OF 2 CHARACTER MNEMONICS.                      
*                                                                               
*                 TABLE IS ORDERED. INSERTIONS MUST BE IN ORDER                 
*        MNEMT2SZ IS TABLE SIZE                                                 
*                                                                               
*    2.1 MNEMC2 - BYTE TABLE OF CHARARACTERS REPRESENTED BY THE                 
*                 MNEMONICS IN MNEMT2. ENTRIES MUST BE ORDERED TO               
*                 PAIR PROPERLY WITH MNEMT2 ENTRIES                             
*                                                                               
*    3.  MNEMT1 - BYTE TABLE OF SINGLE CHARACTER MNEMONICS                      
*                                                                               
*                 TABLE IS ORDERED                                              
*        MNEMT1SZ IS SIZE                                                       
*                                                                               
*    3.1 MNEMC1 - IS CORRESPONDING CHARACTER TABLE, ENTRIES                     
*                 PAIRED WITH MNEMT1                                            
*                                                                               
*                                                                               
* **                                                                            
* * NOTE:IF THIS TABLE IS CHANGED,THE OUTMNEMT AND OUTRANST TABLES              
* **     MUST ALSO BE CHANGED                                                   
*                                                                               
MNEMT3   DATA     X'C1C2E24F'       ABS  ABSOLUTE                               
         DATA     X'C3C1D750'       CAP                                         
         DATA     X'C3D6D459'       COM  COMMENT                                
         DATA     X'C3D7D34A'       CPL  CUP-LEFT                               
         DATA     X'C3D7D967'       CPR  CUP-RIGHT                              
         DATA     X'C3E4D75B'       CUP                                         
         DATA     X'C4C3C442'       DCD  DECODE                                 
         DATA     X'C4C5D37F'       DEL                                         
         DATA     X'C4D3E348'       DLT  DELTA                                  
         DATA     X'C4D9D764'       DRP  DROP                                   
         DATA     X'C4D9E271'       DRS  DIERESIS                               
         DATA     X'C5C3C455'       ECD  ENCODE                                 
         DATA     X'C6C3E341'       FCT  FACTORIAL                              
         DATA     X'D3D6C757'       LOG                                         
         DATA     X'D3D6D275'       LOK  LOCKED FUNCT                           
         DATA     X'D4C1E762'       MAX  MAXIMUM                                
         DATA     X'D4C4E5FE'       MDV  MATRIX DIVIDE                          
         DATA     X'D4C9D544'       MIN  MINIMUM                                
         DATA     X'D5D5C477'       NND  NAND                                   
         DATA     X'D5D6D978'       NOR                                         
         DATA     X'D5D6E35F'       NOT                                         
         DATA     X'D6E4E300'       OUT                                         
         DATA     X'D9C4F163'       RD1  REDUCTION-1ST COORD                    
         DATA     X'D9C5E558'       REV  REVERSE                                
         DATA     X'D9D5C46F'       RND  RANDOM                                 
         DATA     X'D9E5F168'       RV1  REVERSE-1ST COORD                      
         DATA     X'E3C1C205'       TAB  HORIZONTAL TAB                         
         DATA     X'E3C1D26A'       TAK  TAKE                                   
         DATA     X'E3C2D954'       TBR  T-BAR                                  
         DATA     X'E3D7E2B2'       TPS  TRANSPOSE                              
         DATA     X'E4C4D347'       UDL  UNDERSCORED DELTA                      
         DATA     X'E7D7C4B1'       XPD  EXPAND                                 
         DATA     X'E7D7F1B0'       XP1  EXPAND-1ST COORD                       
*                                                                               
MNEMT3X  RES      0                                                             
MNEMT3SZ EQU      MNEMT3X-MNEMT3                                                
*                                                                               
* **                                                                            
* * NOTE:IF THIS TABLE IS CHANGED,THE OUTMNEMT AND OUTRANST TABLES              
* **     MUST ALSO BE CHANGED                                                   
*                                                                               
*                 OVHWTABL. OVBYTABL IS NOT ORDERED IN ITSELF!                  
         BOUND    4                                                             
MNEMT2   DATA,2   0                 OFFSET HALFWORD FOR BDR LOOP                
         DATA,2   X'C2E2'           BS   BACKSPACE                              
         DATA,2   X'C7C4'           GD   GRADE DOWN                             
         DATA,2   X'C7C5'           GE   GREATER THAN OR EQUAL                  
         DATA,2   X'C7D6'           GO   BRANCH                                 
         DATA,2   X'C7E3'           GT   GREATER THAN                           
         DATA,2   X'C7E4'           GU   GRADE UP                               
         DATA,2   X'C9C2'           IB   I-BEAM                                 
         DATA,2   X'C9E2'           IS   ASSIGNMENT                             
         DATA,2   X'D3C5'           LE   LESS THAN OR EQUAL                     
         DATA,2   X'D3E3'           LT   LESS THAN                              
         DATA,2   X'D5C5'           NE   NOT EQUAL                              
         DATA,2   X'D6D9'           OR                                          
         DATA,2   X'D8D8'           QQ   QUOTE QUAD                             
Q1       WHILE    Q1<NBIO                                                       
         DATA,2   X'D8F0'+Q1-1      QI  GRAPHIC AND BLIND I/O                   
         FIN                                                                    
         DATA,2   X'E2C3'           SC   SMALL CIRCLE                           
         DATA,2   X'E4C1',X'E4C2',X'E4C3',X'E4C4',X'E4C5'                       
         DATA,2   X'E4C6',X'E4C7',X'E4C8',X'E4C9'                               
         DATA,2   X'E4D1',X'E4D2',X'E4D3',X'E4D4',X'E4D5'                       
         DATA,2   X'E4D6',X'E4D7',X'E4D8',X'E4D9'                               
         DATA,2   X'E4E2',X'E4E3',X'E4E4',X'E4E5'                               
         DATA,2   X'E4E6',X'E4E7',X'E4E8',X'E4E9'                               
* THE ENTRIES ABOVE ARE FOR UNDERSCORED A TO Z  **                              
MNEMT2X  RES,2    0                                                             
MNEMT2SZ EQU      HA(MNEMT2X)-HA(MNEMT2)-1                                      
*                                                                               
         BOUND    4                                                             
MNEMC2   DATA,1   0                 OFFSET BYTE FOR BDR LOOP                    
         DATA,1   X'08'             BS                                          
         DATA,1   X'73'             GD                                          
         DATA,1   X'76'             GE                                          
         DATA,1   X'FC'             GO                                          
         DATA,1   X'6E'             GT                                          
         DATA,1   X'46'             GU                                          
         DATA,1   X'51'             IB                                          
         DATA,1   X'FD'             IS                                          
         DATA,1   X'74'             LE                                          
         DATA,1   X'4C'             LT                                          
         DATA,1   X'7B'             NE                                          
         DATA,1   X'79'             OR                                          
         DATA,1   X'52'             QQ                                          
Q2       WHILE    Q2<NBIO                                                       
         DATA,1   X'B6'+Q2-1        QI  GRAPHIC AND BLIND I/O                   
         FIN                                                                    
         DATA,1   X'5A'             SC   SMALL CIRCLE                           
         DATA,1   X'81',X'82',X'83',X'84',X'85',X'86',X'87',X'88',X'89'         
         DATA,1   X'91',X'92',X'93',X'94',X'95',X'96',X'97',X'98',X'99'         
         DATA,1   X'A2',X'A3',X'A4',X'A5',X'A6',X'A7',X'A8',X'A9'               
*                                                                               
* **                                                                            
* * NOTE:IF THIS TABLE IS CHANGED,THE OUTMNEMT AND OUTRANST TABLES              
* **     MUST ALSO BE CHANGED                                                   
*                                                                               
*                                                                               
         BOUND    4                                                             
MNEMT1   DATA,1   0                 OFFSET BYTE FOR BDR LOOP                    
         DATA,1   X'4D'             (    LEFT BRACKET                           
         DATA,1   X'5D'             )    RIGHT BRACKET                          
         DATA,1   X'72'             -   MINUS OPERATOR                          
         DATA,1   X'C5'             E    EPSILON                                
         DATA,1   X'C9'             I    IOTA                                   
         DATA,1   X'D6'             O    CIRCLE                                 
         DATA,1   X'D8'             Q    QUAD                                   
         DATA,1   X'D9'             R    RHO                                    
         DATA,1   X'E4'             U    UNDERSCORE                             
         DATA,1   X'E6'             W    OMEGA                                  
MNEMT1X  RES,1    0                                                             
MNEMT1SZ EQU      BA(MNEMT1X)-BA(MNEMT1)-1                                      
*                                                                               
         BOUND    4                                                             
MNEMC1   DATA,1   0                 OFFSET BYDE FOR BDR LOOP                    
         DATA,1   X'B4'             (                                           
         DATA,1   X'B5'             )                                           
         DATA,1   X'60'             -                                           
         DATA,1   X'45'             E                                           
         DATA,1   X'49'             I                                           
         DATA,1   X'56'             O                                           
         DATA,1   X'53'             Q                                           
         DATA,1   X'6C'             R                                           
         DATA,1   X'6D'             U                                           
         DATA,1   X'66'             W                                           
*                                                                               
         PAGE                                                                   
*                                                                               
* OVERSTRIKE TABLES-INPUT FORMATION OF OVERSTRIKES                              
*    1.  OVHWTABL-TABLE OF HALFWORDS REPRESENTING VALID OVERSTRIKE              
*                 COMBINATIONS. LEFTMOST CHARACTER IS ALWAYS  SMALLER.          
*                 TABLE IS ORDERED-SMALLER TO LARGER VALUES                     
*                 INSERTIONS MUST BE IN ORDER                                   
*    2.  OVBYTABL-TABLE OF BYTE VALUES FOR VALID OVERSTRIKES                    
*                 MUST BE ORDERED TO MATCH TABLE POSITIONS WITH                 
*                 OVHWTABL ENTRIES                                              
*    3.  TABLSIZ  IS NUMBER OF ENTRIES IN OVHWTABL(AND OVBYTABL)                
*    4.  PWR2     IS POWER OF 2 USED IN BINARY SEARCH.                          
*                 IF TABLSIZ IS = OR GREATER THAN 2EXPN AND LESS THAN           
*                 2EXP(N+1),THEN PWR2 SHOULD BE EQUATED TO N                    
*                                                                               
*                                  *INDICATES THIS ISA 'VISUAL FIDELITY'        
*                                   ENTRY-THESE ENTRIES CAN BE DELETED          
*                                   FROM THE TABLES IF REPEAT OVERSTRIK-        
*                                   ES ARE NOT TO BE ALLOWED                    
*                                                                               
* **                                                                            
* * NOTE:IF THIS TABLE IS CHANGED,THE OUTMNEMT AND OUTRANST TABLES              
* **     MUST ALSO BE CHANGED                                                   
*                                                                               
*                                                                               
         BOUND    4                                                             
OVHWTABL DATA,2   X'414B'          *BANG     DOT       BANG1                    
         DATA,2   X'417D'          *BANG     QUOTE     BANG2                    
         DATA,2   X'4251'          *BASE     IBEAM     IBEAM1                   
         DATA,2   X'4255'           BASE     TEE       IBEAM2                   
         DATA,2   X'434F'          *BUCKS    ABS       BUCKS1                   
         DATA,2   X'4361'          *BUCKS    COMPRESS  BUCKS2                   
         DATA,2   X'43E2'          *BUCKS    S         BUCKS3                   
         DATA,2   X'4648'          *GRADEUP  DELTA     GRADEUP1                 
         DATA,2   X'464F'          *GRADEUP  ABS       GRADEUP2                 
         DATA,2   X'4748'          *UDELTA   DELTA     UDELTA1                  
         DATA,2   X'476D'          *UDELTA   USCORE    UDELTA2                  
         DATA,2   X'484F'           DELTA    ABS       GRADEUP3                 
         DATA,2   X'486D'           DELTA    USCORE    UDELTA3                  
         DATA,2   X'4B5E'          *DOT      SEMI      SEMI1                    
         DATA,2   X'4B6B'          *DOT      COMMA     COMMA1 (OF 1)            
         DATA,2   X'4B6F'          *DOT      QUERY     QUERY1 (OF 1)            
         DATA,2   X'4B7A'          *DOT      COLON     COLON1 (OF 1)            
         DATA,2   X'4B7D'           DOT      QUOTE     BANG3                    
         DATA,2   X'4F56'           ABS      CIRC      ROTATE1                  
         DATA,2   X'4F58'          *ABS      ROTATE    ROTATE2                  
         DATA,2   X'4F73'          *ABS      GRADOWN   GRADOWN1                 
         DATA,2   X'4F7F'           ABS      DEL       GRADOWN2                 
         DATA,2   X'4FE2'           ABS      S         BUCKS4                   
         DATA,2   X'5059'          *DOWNU    LAMP      LAMP1                    
         DATA,2   X'505A'           DOWNU    OUTER     LAMP2                    
         DATA,2   X'5155'          *IBEAM    TEE       IBEAM3                   
         DATA,2   X'5253'          *QQUAD    QUAD      QQUAD1                   
         DATA,2   X'527D'          *QQUAD    QUOTE     QQUAD2                   
         DATA,2   X'537D'           QUAD     QUOTE     QQUAD3                   
L1       WHILE    L1<NBIO                                                       
         DATA,2   X'53B6'+L1-1     *QUAD     QUADI     QUADI1                   
         FIN                                                                    
L2       WHILE    L2<NBIO                                                       
         DATA,2   X'53F0'+L2-1      QUAD     QUADI     QUADI2                   
         FIN                                                                    
         DATA,2   X'53FB'           QUAD     DIVIDE    DOMINO1                  
         DATA,2   X'53FE'          *QUAD     DOMINO    DOMINO2                  
         DATA,2   X'5455'          *TBAR     TEE       TBAR1                    
         DATA,2   X'5472'          *TBAR     NEGSIGN   TBAR2                    
         DATA,2   X'5572'           TEE      NEGSIGN   TBAR3                    
         DATA,2   X'5657'          *CIRC     LOG       LOG1                     
         DATA,2   X'5658'          *CIRC     ROTATE    ROTATE3                  
         DATA,2   X'565C'           CIRC     STAR      LOG2                     
         DATA,2   X'5660'           CIRC     MINUS     FLIP1                    
         DATA,2   X'5668'          *CIRC     FLIP      FLIP2                    
         DATA,2   X'56B1'           CIRC     EXPAND    TRANSPOSE1               
         DATA,2   X'56B2'          *CIRC     TRANSPOSE TRANSPOSE2               
         DATA,2   X'575C'          *LOG      STAR      LOG3                     
         DATA,2   X'595A'          *LAMP     OUTER     LAMP3                    
         DATA,2   X'5E6B'          *SEMI     COMMA     SEMI2                    
         DATA,2   X'5E7A'          *SEMI     COLON     SEMI3                    
         DATA,2   X'5F70'           NOT      AND       NAND1                    
         DATA,2   X'5F75'          *NOT      LOCK      LOCK1                    
         DATA,2   X'5F77'          *NOT      NAND      NAND2                    
         DATA,2   X'5F78'          *NOT      NOR       NOR1                     
         DATA,2   X'5F79'           NOT      OR        NOR2                     
         DATA,2   X'5F7F'           NOT      DEL       LOCK2                    
         DATA,2   X'6061'           MINUS    COMPRESS  MCOMP1                   
         DATA,2   X'6063'          *MINUS    MCOMP     MCOMP2                   
         DATA,2   X'6068'          *MINUS    FLIP      FLIP3                    
         DATA,2   X'60B0'          *MINUS    MEXPAND   MEXPAND1                 
         DATA,2   X'60B1'           MINUS    EXPAND    MEXPAND2                 
         DATA,2   X'6163'          *COMPRESS MCOMP     MCOMP3                   
         DATA,2   X'61E2'           COMPRESS S         BUCKS5                   
         DATA,2   X'6B7A'          *COMMA    COLON     SEMI4                    
         DATA,2   X'7077'          *AND      NAND      NAND3                    
         DATA,2   X'737F'          *GRADOWN  DEL       GRADOWN3                 
         DATA,2   X'757F'          *LOCK     DEL       LOCK3                    
ENDOVHW  DATA,2   X'7879'          *NOR      OR        NOR3                     
TABLSIZ  EQU      HA(ENDOVHW)-HA(OVHWTABL)+1                                    
I        WHILE    I<8                                                           
         DO       ((1**I)<=TABLSIZ)&(1**(1+I)>TABLSIZ)                          
PWR2     SET      I                                                             
         FIN                                                                    
         FIN                                                                    
*                                                                               
*                                                                               
*NEGHWTBL-TABLE OF HALFWORDS WHICH  'CH' TREATS AS NEGATIVE                     
*         USED FOR OVERSTRIKE VALIDITY TEST                                     
         BOUND    4                                                             
NEGHWTBL DATA,2   0                 OFFSET FOR BDR LOOP                         
         DATA,2   X'B0B1'          *MEXPAND  EXPAND    MEXPAND3                 
         DATA,2   X'B1B2'          *EXPAND   TRANSPOSE TRANSPOSE3               
L3       WHILE    L3<NBIO                                                       
         DATA,2   X'B6F0'+X'101'*(L3-1)  QUAD  QUADI  *QUADI3                   
         FIN                                                                    
         DATA,2   X'FBFE'          *DIVIDE   DOMINO    DOMINO3                  
NEGHWTX  RES,2    0                                                             
NEGHWTSZ EQU      HA(NEGHWTX)-HA(NEGHWTBL)-1                                    
         BOUND    4                                                             
OVBYTABL DATA,1   X'41'            *BANG1                                       
         DATA,1   X'41'            *BANG2                                       
         DATA,1   X'51'            *IBEAM1                                      
         DATA,1   X'51'             IBEAM2                                      
         DATA,1   X'43'            *BUCKS1                                      
         DATA,1   X'43'            *BUCKS2                                      
         DATA,1   X'43'            *BUCKS3                                      
         DATA,1   X'46'            *GRADEUP1                                    
         DATA,1   X'46'            *GRADEUP2                                    
         DATA,1   X'47'            *UDELTA1                                     
         DATA,1   X'47'            *UDELTA2                                     
         DATA,1   X'46'             GRADEUP3                                    
         DATA,1   X'47'             UDELTA3                                     
         DATA,1   X'5E'            *SEMI1                                       
         DATA,1   X'6B'            *COMMA1                                      
         DATA,1   X'6F'            *QUERY1                                      
         DATA,1   X'7A'            *COLON1                                      
         DATA,1   X'41'             BANG3                                       
         DATA,1   X'58'             ROTATE1                                     
         DATA,1   X'58'            *ROTATE2                                     
         DATA,1   X'73'            *GRADOWN1                                    
         DATA,1   X'73'             GRADOWN2                                    
         DATA,1   X'43'             BUCKS4                                      
         DATA,1   X'59'            *LAMP1                                       
         DATA,1   X'59'             LAMP2                                       
         DATA,1   X'51'            *IBEAM3                                      
         DATA,1   X'52'            *QQUAD1                                      
         DATA,1   X'52'            *QQUAD2                                      
         DATA,1   X'52'             QQUAD3                                      
B1       WHILE    B1<NBIO                                                       
         DATA,1   X'B6'+B1-1       *QUADI1                                      
         FIN                                                                    
B2       WHILE    B2<NBIO                                                       
         DATA,1   X'B6'+B2-1        QUADI2                                      
         FIN                                                                    
         DATA,1   X'FE'             DOMINO1                                     
         DATA,1   X'FE'            *DOMINO2                                     
         DATA,1   X'54'            *TBAR1                                       
         DATA,1   X'54'            *TBAR2                                       
         DATA,1   X'54'             TBAR3                                       
         DATA,1   X'57'            *LOG1                                        
         DATA,1   X'58'            *ROTATE3                                     
         DATA,1   X'57'             LOG2                                        
         DATA,1   X'68'             FLIP1                                       
         DATA,1   X'68'            *FLIP2                                       
         DATA,1   X'B2'             TRANSPOSE1                                  
         DATA,1   X'B2'            *TRANSPOSE2                                  
         DATA,1   X'57'            *LOG3                                        
         DATA,1   X'59'            *LAMP3                                       
         DATA,1   X'5E'            *SEMI2                                       
         DATA,1   X'5E'            *SEMI3                                       
         DATA,1   X'77'             NAND1                                       
         DATA,1   X'75'            *LOCK1                                       
         DATA,1   X'77'            *NAND2                                       
         DATA,1   X'78'            *NOR1                                        
         DATA,1   X'78'             NOR2                                        
         DATA,1   X'75'             LOCK2                                       
         DATA,1   X'63'             MCOMP1                                      
         DATA,1   X'63'            *MCOMP2                                      
         DATA,1   X'68'            *FLIP3                                       
         DATA,1   X'B0'            *MEXPAND1                                    
         DATA,1   X'B0'             MEXPAND2                                    
         DATA,1   X'63'             MCOMP3                                      
         DATA,1   X'43'             BUCKS5                                      
         DATA,1   X'5E'            *SEMI4                                       
         DATA,1   X'77'            *NAND3                                       
         DATA,1   X'73'            *GRANDOWN3                                   
         DATA,1   X'75'            *LOCK3                                       
         DATA,1   X'78'            *NOR3                                        
*                                                                               
         BOUND    4                                                             
NEGBYTBL DATA,1   0                 OFFSET FOR BDR LOOP                         
         DATA,1   X'B0'            *MEXPAND3                                    
         DATA,1   X'B2'            *TRANSPOSE3                                  
B3       WHILE    B3<NBIO                                                       
         DATA,1   X'B6'+B3-1       *QUADI3                                      
         FIN                                                                    
ENDOVBY  DATA,1   X'FE'            *DOMINO3                                     
*                                                                               
         PAGE                                                                   
*                                                                               
*  CONSTANT REGION                                                              
*                                                                               
         BOUND    8                                                             
LETTERS  DATA     X'000000C1'       A                                           
         DATA     X'000000E9'       Z                                           
ULETTERS DATA     X'00000081'       A-UNDERSCORE                                
         DATA     X'000000A9'       Z-UNDERSCORE                                
UAUZ     DATA     X'FFFFE4C1'       UA +LEADING 1'S                             
         DATA     X'FFFFE4E9'       UZ +LEADING 1'S                             
FFFFFF00 DATA     X'FFFFFF00'                                                   
FFFF0000 DATA     X'FFFF0000'                                                   
         PAGE                                                                   
*                                                                               
*  APL INPUT DRIVERS:                                                           
*                                                                               
*   INPDIR-DIRECT INPUT                                                         
*   INPEVAL-EVALUATED INPUT                                                     
*                                                                               
*   THESE ROUTINES GENERATE APPROPRIATE PROMPTS                                 
*                  CALL RELEASER TO FREE UNUSED MEMORY                          
*                  SET FLAGS                                                    
*                  CALL APLINPUT TO INPUT A SOURCE LINE                         
*                  CALL CS1 TO CODESTRING THE INPUT                             
*                  BRANCH TO CX TO EXECUTE THE INPUT                            
*                                                                               
INPDIR   LI,R11   1                                                             
         STW,R11  MODE              SET DIRECT MODE                             
         MTW,1    OBSFLAG           INCR. OBSERVE-FLAG (-1 = YES).              
         BLEZ     INPSOURC                                                      
         LI,R11   0                 SET IT ZERO IF GREATER.                     
         STW,R11  OBSFLAG                                                       
         B        INPSOURC                                                      
INPEVAL  LW,R8    ON%OFF            CHECK IF OFF LINE                           
         BEZ      INPSOURC           YES-SKIP PROMPT                            
         LI,R8    ERRORCHR          WA(EVALUATED INPUT PROMPT)                  
         LI,R9    2                  SIZE (2 BYTES)                             
         STW,R9   MODE               ALSO-SET EVALUATED INPUT MODE              
         LI,R10   1                   BYTE DISP (BYTES 1&2 OF ERRORCHR)         
         BAL,R7   WROUT             GENERATE PROMPT                             
INPSOURC BAL,R11  PRMTBLNK          GENERATE BLANK PROMPT                       
         BAL,R11  RELEASER          RELEASE AVAILABLE CORE                      
INPLSCER LI,R11   0                 ENTRY FROM LINE-SCAN ERROR                  
         STW,R11  QCNT              RESET QUOTE COUNT                           
         MTW,0    BREAKFLG          CHECK FOR HANGUP                            
         BLZ      BCONTOFF           YES-DO CONTINUE AND OFF                    
         STW,R11  BREAKFLG           AND BREAK FLAG                             
INPRET   BAL,R11  APLINPUT          INPUT A LINE                                
         LI,R15   %                 NOTE POS. IN R15 FOR ERR ANALYSIS.          
BCSX     BAL,R12  CS1               CODESTRING THE LINE.                        
BCX      B        CX                COMMENCE FIRING                             
*                                                                               
* INPXTEND-EXTEND INPUT LINE (UNBALANCED QUOTES)                                
*                                                                               
*  R11 USED.                                                                    
*                                                                               
*                                                                               
INPXTEND MTW,0    BREAKFLG          CHECK FOR HANGUP                            
         BLZ      BRESXTND            YES, HANGUP CURRENT CODESTRING.           
         BAL,R11  APLINPUT          GET INPUT LINE -- NO PROMPT.                
BRESXTND B        RESXTEND   *BREF* RESUME FOR EXTENSION OF CURR. CS.           
*                                                                               
* INPQQUAD-ROUTINE TO INPUT 'TEXT' WHEN CALLED BY EX. OF QUOTE-QUAD             
*                                                                               
*    ON EXIT,R11=CHARACTER COUNT(INCLUDING CR)                                  
*            R13=0 IF NOT  O-U-T EXIT                                           
*            R13<0 IF HANG-UP DETECTED.                                         
*    ALL OTHER REGISTERS SAVED AND RESTORED                                     
*                                                                               
*                                                                               
         LOCAL    NOPROMPT                                                      
INPQQUAD LI,R11   0                 SET TO INDICATE THAT                        
         STW,R11  OUTSIZ             INPUT IS NOT PREDECED BY PROMPT            
         LW,R13   BREAKFLG          CHECK FOR HANG-UP...                        
         BLZ      BRESQQAD            YES, RESUME QQUAD PROCESSING NOW.         
         LI,R11   255               BYTE MASK                                   
         AND,R11  ERRORCHR           CHECK IF PROMPT REQUIRED                   
         BEZ      NOPROMPT            NO                                        
         LCI      4                    YES-SAVE R7-R10                          
         STM,R7   SAVE312                                                       
         LI,R8    ERRORCHR          WA(COLON)                                   
         LI,R9    1                 SIZE-1 BYTE                                 
         LI,R10   2                  OFFSET- COLON IS BYTE 2                    
         BAL,R7   CALWROUT          OUTPUT THE BEAST                            
         LCI      4                                                             
         LM,R7    SAVE312           RESTORE  R7-R10                             
NOPROMPT BAL,R11  APLINPUT          INPUT A LINE                                
QQINRET  LW,R11   HICOL                                                         
         AI,R11   -BA(IMAGE)+1      GET BYTE  COUNT (INCLUDING CR)              
         LW,R13   OUTFLAG           INDICATE  O-U-T IF PRESENT                  
BRESQQAD B        RESQQUAD   *BREF* RESUME QUOTE-QUAD PROCESSING.               
*                                                                               
* INPF-INPUT A FUNCTION LINE,AFTER PROMPTING WITH LINE #                        
*                                                                               
*   ON ENTRY, LINE # IS IN IMAGE  R3=CHARACTER COUNT                            
*                                                                               
*   EXIT IS TO FIHANDLER WITH INPUT LINE IN IMAGE AND HICOL SET                 
*                                                                               
*     MOST REGISTERS USED-NONE SAVED                                            
*                                                                               
INPF     LCW,R11  BREAKFLG          CHECK FOR HANGUP                    U12-0006
         BGZ      BCONTOFF           YES-- CONTINUE-OFF                 U12-0007
         AWM,R11  BREAKFLG           NO-- RESET BREAK IF SET            U12-0008
         BAL,R11  PRMTIMAG          GENERATE PROMPT                     U12-0009
INPFAPIN BAL,R11  APLINPUT           INPUT LINE                                 
BFIHNDLR B        FIHANDLR    *BREF* GO TO FIHANDLR TO PROCESS                  
*                                                                               
* INPFAPND--INPUT FUNCTION LINE APPENDAGE (SEE INPF)                            
*                                                                               
INPFAPND LCW,R11  BREAKFLG           CK FOR HANGUP...                           
         BGZ      BCONTOFF             YEP.                                     
         AWM,R11  BREAKFLG             NOPE, CLEAR IF BREAK.                    
         B        INPFAPIN                                                      
*                                                                               
* INP4MERG-ROUTINE TO MERGE INPUT FOR FUNCTION LINE EDIT                        
*                                                                               
*   USES MOST REGISTERS-SAVES NONE                                              
*                                                                               
*   EXITS TO FIHANDLER                                                          
*                                                                               
         LOCAL    SINBUF,SINDEX1,SINDEX2                                        
INP4MERG STW,R3   HICOL             SAVE # OF CHARS                             
         LW,R6    ON%OFF             CHECK IF OFF-LINE                          
         BEZ      NOPROMPT            YES-SKIP THIS JAZZ                        
         BAL,R11  PRMTIMAG            NO-ISSUE PROMPT                           
         LW,R3    HICOL             GET NO. OF CHARS                    12-00001
         LI,R11   X'40'              SET BLANK                          12-00002
BLNKRT   STB,R11  IMAGE,R3          REPLACE 'IDLE' AND RIGHT END OF     12-00003
         AI,R3    1                  IMAGE BUFFER WITH BLANKS           12-00004
         CI,R3    MAXCOL                                                12-00005
         BL       BLNKRT                                                12-00006
         LW,R7    BSPFLAG           GET BSP FLAG 1=YES 0=NO                     
         LW,R9    BLNKBKSP,R7        GET WORD OF BLANKS OR BSP'S                
         LI,R6    DWSIZIM                                                       
SINBUF   STD,R9   INBUF-2,R6        FILL INBUF                                  
         BDR,R6   SINBUF                                                        
         LB,R8    CRORBS,R7         SET CR OR BS AS 1ST CHAR.                   
         STB,R8   INBUF                                                         
         EXU      SINDEX1,R7        ESTABLISH INDEX                             
         EXU      SINDEX2,R7         FOR IDLE CHARACTER                         
         LI,R8    X'16'               IDLE                                      
         STB,R8   INBUF,R5                                                      
         LW,R9    R5                SET SIZE                                    
         AI,R9    1                                                             
         LI,R8    INBUF             ADDRESS                                     
         BAL,R7   WROUTWB           -OUTPUT                                     
NOPROMPT STW,R6   OUTSIZ            RESET OUTSIZ FOR APLINPUT                   
         LCW,R6   BREAKFLG          CHECK FOR HANGUP                    U12-0011
         BGZ      BCONTOFF           YES-- CONTINUE-OFF                 U12-0012
         LW,R6    MERGECOL                                                      
         AI,R6    -1                SET START POINT-1 IN IMAGE                  
         BAL,R11  APLINMRG           MERGE INPUT                                
         B        BFIHNDLR          GO TO FIHANDLR TO PROCESS                   
BLNKBKSP DATA     X'40404040',X'08080808'                                       
CRORBS   DATA     X'15080000'                                                   
SINDEX1  LW,R5    MERGECOL          GET MERGECOL (BLANK COUNT)                  
         LW,R5    HICOL             GET HICOL                                   
SINDEX2  AI,R5    1                 ADD 1 FOR CR                                
         SW,R5    MERGECOL          SUBTRACT MERGECOL,FORM # OF BSP'S           
*                                                                       12-00014
* INPXEQ-FAKE INPUT FOR 'EXECUTE'                                       12-00015
*                                                                       12-00016
*        MAKES SPECIAL CALL TO APLINPUT                                 12-00017
*              REGISTERS ALL VOLATILE                                   12-00018
*        NORMAL EXIT TO CX    ERROR EXIT TO ERXEQ                       12-00019
*                                                                       12-00020
INPXEQ   LI,R9    2                                                     12-00021
         STW,R9   MODE              SET EVALUATED INPUT MODE            12-00022
         STW,R9   QCNT              SET QUOTE COUNT EVEN                12-00023
         BAL,R11  APLINPUT          CALL APLINPUT                       12-00024
INPXEQR  LW,R11   QCNT                                                  12-00025
         CI,R11   1                 CHECK FOR UNBALANCED QUOTES         12-00026
         BANZ     INPXEQUQ           YES                                12-00027
         BAL,R15  BCSX               NO, CODESTR. & XEQ THE LINE.               
INPXEQUQ LI,R8    IDOPENQT          = ERROR I.D. FOR 'OPEN QUOTE'.              
         BAL,R7   CMDERRH           HANDLE LIKE A CMD ERROR.                    
         LI,R3    -BA(IMAGE)                                                    
         AWM,R3   HICOL             READJUST HICOL                              
INPXEQBC LW,R3    HICOL                                                         
         BAL,R12  EDUMPLIN          DISPLAY OFFENDING LINE.                     
         B        ERXEQ             GO TO EXECUTE-OPERATOR ERROR RETURN.        
         PAGE                                                                   
*                                                                               
*  COMMON INPUT ROUTINE-HANDLES ALL TERMINAL INPUT EXCEPT 'BLIND' INPUT         
*                                                                               
*         INPUT IS READ INTO  INBUF BY CALRDAPL                                 
*                                                                               
*         AN INPUT TRANSLATION TABLE, INTRANS, IS USED TO TRANSLATE             
*                 SINGLE CHARACTERS,AS REQUIRED,TO APL MAPPING. THIS            
*                 TABLE IS A FUNCTION OF TERMINAL TYPE                          
*                                                                               
*         SPECIAL CHARACTERS ARE RECOGNIZED AND PROCESSED:                      
*                 BADCHAR           ILLEGAL CHARACTER                           
*                 NEWLINE           CR OR LF                                    
*                 MNEMONIC          %                                           
*                 FORMFEED          CONTROL-L ON TTY                            
*                 EOTATTN           ATTN ON 2741                                
*                 HTAB              HORIZONTAL TAB                              
*                 IDLE              IDLE CHARACTER                              
*                 INDEX             2741 LINE FEED(NO CR)                       
*                 BACKSP            BACKSPACE                                   
*                 QUOTE                                                         
*                                                                               
*         PROCESSED INPUT IS BUILT IN 'IMAGE',WHICH IS PRESET TO BLANKS         
*                                                                               
*         ORDINARY CHARACTERS ARE PROCESSED AS FOLLOWS:                         
*                 BLANK                      SKIP IT                            
*                 IMAGE POSITION BLANK       STORE NEW CHARACTER                
*                 IMAGE POSITION QUOTE       DECREMENT QUOTE COUNT              
*                 IMAGE POSITION SAME                                           
*                       AS NEW CHARACTER     STOOE NEW CHARACTER                
*                 IMAGE POSITION DIFFERS                                        
*                       FROM NEW CHAR        DO OVERSTRIKE PROCESSING           
*                                                                               
*         OVERSTRIKE PROCESSOR SEARCHES FOR VALID OVERSTRIKE                    
*                 LETTER-UNDERSCORE OVERSTRIKES ARE CHECKED AT ALPHTEST         
*                 OTHER OVERSTRIKES ARE CHECKED AT TABLTEST                     
*                       OVHWTABL AND OVBYTABL TABLES ARE USED FOR SEARCH        
*                       BINARY SEARCH IS USED                                   
*                 CKOUT IS FINAL CHECK FOR SPECIAL OVERSTRIKE                   
*                       0-BS-U-BS-T                                             
*                 BADCHAR IS REACHED IF NO VALID OVERSTRIKE IS FOUND            
*                                                                               
*         BADCHAR PROCESSOR                                                     
*                 FLAGS LOWEST BAD-CHARACTER IN 'IMAGE'                         
*            **** PROCESSING CONTINUES BECAUSE INPUT LINE MAY BE                
*            **** COMPOSED OF MORE THAN 1 RECORD AND BECAUSE SUBSEQUENT         
*            **** BS SEQUENCE AND ATTN MAY EXPUNGE BAD CHARACTERS               
*                                                                               
*         HTAB PROCESSOR                                                        
*                 SPACES INPUT ON 'IMAGE' AS INDICATED BY TAB SETTINGS          
*                                                                               
*         BACKSP  PROCESSOR                                                     
*                 ADJUSTS IMAGE COLUMN POSITION FOR BACKSPACE                   
*                                                                               
*         MNEMONIC PROCESSOR                                                    
*                PROCESSES FORMS %XXX-GENERATES APL CHARS.                      
*                 ACTUAL PROCESSING DEFERRED UNTIL END OF INPUT LINE            
*                 FIRST PASS RECORDS PRESENCE OF MNEMONIC START CHAR.           
*                                                                               
*                 PROCESSING IS PRIMARILY LINEAR SEARCH OF ORDERED              
*                   TABLES: MNEMT3 FOR 3CHAR                                    
*                           MNEMT2 FOR 2CHAR (RESULT IN MNEMC2)                 
*                           MNEMT1 FOR 1CHAR (RESULT IN MNEMC1)                 
*                   % IS SET IF MNEMONIC NOT FOUND                              
*                   %OUT SETS OUTFLAG AND BCHAR                                 
*                                                                               
*         FORMFEED,EOTATTN,AND INDEX PROCESSORS                                 
*                 HANDLE LINE EDIT OPERATIONS                                   
*                   BLANK TO RIGHT OF EDIT (OR BCHAR) POSITION                  
*                   DECREMENT QUOTE COUNT FOR DELETED QUOTES                    
*                   ISSUE PROMPT AND CONTINUE INPUT AT EDIT POSITION            
*                                                                               
*         NEWLINE PROCESSOR                                                     
*                 CHECKS FOR BAD CHAR OR OUT                                    
*                 BAD CHAR RESULTS IN RIGHT END EDIT, BAD CHAR MESSAGE,         
*                 PROMPT WITH GOOD PART OF LINE, AND RETURN TO INPUT            
*                                                                               
*                 OUT RESULTS IN SETTING LINE EMPTY AND LEAVING OUTFLAG         
*                 SET                                                           
*                                                                               
*                 NORMAL EXIT ADDS CR, SETS HICOL=SIZE, AND EXITS               
*                                                                               
*        R11 IS LINK                                                            
*                                                                               
*        R3 TO R12 ARE SAVED,USED,AND RESTORED                                  
*                                                                               
*        INTERNALLY,R6 POINTS TO POSITION IN IMAGE, R7(USUALLY) TO              
*        POSITION IN INBUF                                                      
*                                                                               
*        ROUTINES CALLED: CALWROUT -OUTPUT A FIXED PROMPT                       
*                                   USES R7-R10                                 
*                         BCHAROUT -CONVERT & OUTPUT IMAGE  -                   
*                                   MAY USE R3 TO R12                           
         LOCAL    BLANKIT,RESEDIT                                               
APLINMRG LCI      10                ENTRY FOR MERGED INPUT (LINE EDIT)          
         STM,R3   SAVE312                                                       
         LW,R7    TERMTYPE          SET MNEMONIC FLAG IF                12-00038
         AI,R7    -1                 TERMINAL TYPE                      12-00039
         STW,R7 MNEMFLG               IS NOT 1                          12-00040
         LI,R7    0                                                             
         B        RESEDIT                                                       
APLINPUT LCI      10                                                            
         STM,R3   SAVE312           SAVE REGISTERS                              
         LI,R6    -1                 R6=COL                                     
         STW,R6   HICOL             PRESET HICOL                                
         LI,R7    DWSIZIM                                                       
         LW,R9    BLANKS                                                        
BLANKIT  STD,R9   IMAGE-2,R7        BLANK THE IMAGE BUFFER                      
         BDR,R7   BLANKIT                                                       
         STW,R7   MNEMFLG           SET MNEMONIC FLAG 'OFF'             12-00042
RESEDIT  STD,R7   EDITCK            RESET EDITCK AND OUTFLAG                    
         LI,R8    1000                                                          
         STW,R8   BCHAR             PRESET BAD CHAR POSITION-TOO HIGH           
         LI,R8    INPREAL           SET INPUT SWITCH TO REAL INPUT              
         STW,R8   INSWITCH                                                      
         CI,R11   INPXEQR           CHECK IF 'EXECUTE' ENTRY            12-00045
         BNE      SETCAL             NO                                 12-00046
         MTW,INPFAKE-INPREAL   INSWITCH     SWITCH TO FAKE INPUT                
         LI,R7    -1                         AND SKIP ACTUAL INPUT.             
         B        NEXTCOL                     START AT INBUF.                   
*                                                                               
*  READ AN INPUT  RECORD  *                                                     
*                                                                               
SETCAL   LW,R11   BREAKFLG          CHECK FOR 'HANGUP'                          
         BLZ      CRONLY             YES-DON'T TRY INPUT                        
         BAL,R11  RDAPL                                                         
*                                                                               
*  ACCESS A BYTE AND OPERATE ON IT  *                                           
*                                                                               
         LOCAL    OK,CHKTYPE                                                    
NEXTCOL  BAL,R11  NEXTBYTE          GET & TRANSLATE BYTE                        
         AI,R6    1                 UPDATE COL                                  
         CI,R6    MAXCOL                                                        
         BL       OK                                                            
         LI,R8    IDTRUNC           = ERROR I.D. FOR 'TRUNCATED INPUT'.         
         BAL,R7   CMDERRH           HANDLE LIKE A CMD ERROR.                    
         LW,R11   SAVE312+8         RESTORE LINK REGISTER               12-00060
         CI,R11   INPXEQR            CHECK FOR 'EXECUTE'                12-00061
         BNE      CRONLY              NO-SCRAP LINE                     12-00062
         B        INPXEQBC            YES-DISPLAY THE BEAST             12-00063
OK       CW,R6    HICOL                                                         
         BLE      CHKTYPE                                                       
         STW,R6   HICOL             UPDATE HICOL AS INDICATED                   
CHKTYPE  CI,R5    BLANK             3 TYPES-SPECIAL,BLANK,ORDINARY              
         BG       ORDINARY                                                      
         BL       SPECIAL,R5        BELOW BLANK IS A BRANCH VECTOR              
         B        NEXTCOL           BLANK-NO CHANGE TO IMAGE                    
*                                                                               
*  ACCESS A BYTE AND TRANSLATE IT  *                                            
*                                                                               
NEXTBYTE AI,R7    1                 UPDATE POINTER                              
         LB,R5    INBUF,R7           GET UNTRANSLATED BYTE                      
         B       *INSWITCH          (INPREAL OR INPFAKE)                        
INPREAL  BEZ      SETCAL             END OF RECORD BUT NOT OF LINE              
INPXLATE LB,R5    INTRANS,R5          GET TRANSLATED VALUE OF BYTE              
         B       *R11                                                           
INPFAKE  CI,R5    BLANK             CHECK VS BLANK                              
         BLE      INPXLATE           LOW-NORMAL TRANSLATE IS OK                 
         CI,R5    X'7D'             CHECK VS QUOTE                              
         BNE      INPQD              NO                                         
         LI,R5    9                  YES-SET SPECIAL VALUE FOR QUOTE            
         B       *R11                    AND RETURN                             
INPQD    CI,R5    X'43'             CHECK VS DOLLAR SIGN                        
         BNE     *R11                NO-RETURN WITH NO TRANSLATION              
         LI,R5    2                  YES-SET SPECIAL VALUE FOR                  
         B       *R11                   DOLLAR SIGN AND RETURN                  
*                                                                               
*  SPECIAL BYTE-BRANCH TO APPROPRIATE ROUTINE  *                                
*                                                                               
SPECIAL  B        BADCHAR         0                                 @@@@        
         B        NEWLINE         1  CR OR LF                          @        
         B        MNEMONIC        2  %                                 @        
         B        FORMFEED        3  CONTROL L                         @        
         B        EOTATTN         4  ATTN                              @        
         B        HTAB            5  TAB                               @        
         B        IDLEPR          6  IDLE                              @        
         B        INDEX           7  INDEX                             @        
         B        BACKSP          8  BS                                @        
         LI,R5    X'7D'           9  QUOTE                          @@@@        
         LB,R4    IMAGE,R6                                                      
         CI,R4    BLANK             CHECK FOR OVERSTRIKE                        
         BNE      CMPRBYTE                                                      
         MTW,1    QCNT              UPDATE QUOTE COUNT FOR TRUE QUOTE           
         B        SETBYTE                                                       
*                                                                               
*  PROCESS ORDINARY BYTE   *                                                    
*                                                                               
         LOCAL                                                                  
ORDINARY LB,R4    IMAGE,R6                                                      
         CI,R4    BLANK             CHECK FOR OVERSTRIKE                        
         BE       SETBYTE            NO                                         
         CI,R4    X'7D'              YES-CHECK FOR OLD QUOTE                    
         BNE      CMPRBYTE            NO                                        
         MTW,-1   QCNT                YES-DECREMENT QUOTE COUNT                 
CMPRBYTE CW,R5    R4                CHECK FOR DUPLICATION                       
         BNE      OVERSTRK           NO-OVERSTRIKE PROCESSING REQUIRED          
SETBYTE  STB,R5   IMAGE,R6          SET BYTE                                    
         B        NEXTCOL            AND CONTINUE                               
*                                                                               
*  OVERSTRIKE PROCESSING  *                                                     
*                                                                               
         LOCAL    ALPHTEST,UATOZ,UNDRSCR,CMPRHW,FOUND,UPPER,PLUS,MINUS          
         LOCAL    NXTCMP,LASTCASE                                               
         LOCAL    NEGHW,FOUNDNEG                                                
OVERSTRK BG       ALPHTEST          CHECK  R4 VS R5                             
         XW,R4    R5                 MAKE R4 THE LESSER                         
ALPHTEST CI,R4    X'6D'             UNDERSCORE                                  
         BNE      UATOZ              NO                                         
         CLM,R5   LETTERS            YES-CHECK LETTER RANGE                     
         BCR,9    UNDRSCR             OK                                        
         CLM,R5   ULETTERS            NO-CHECK REDUNDANT UNDERSCORE             
         BCR,9    SETBYTE                YES-SET IT                             
UATOZ    CLM,R4   ULETTERS          CHECK FOR UNDERSCORED LETTER                
         BCS,9    TABLTEST           NO-GO TO TABLE TEST                        
         AI,R4    BLANK              YES-SWITCH TO LETTER                       
         CW,R4    R5                  COMPARE LETTERS                           
         BNE      BADCHAR              NO-GO                                    
UNDRSCR  AI,R5    -BLANK            SET UNDERSCORE                              
         B        SETBYTE                                                       
*                                                                               
*  TABLE LOOKUP PART OF OVERSTRIKE PROCESSING-BINARY SEARCH  *                  
*                                                                               
TABLTEST STB,R4   R4                R4 BYTE 0  SET  TO LESSER BYTE              
         LI,R3    1                                                             
         STB,R5   R4,R3             R4 BYTE 1  SET  TO GREATER BYTE             
         LH,R4    R4                R4 SET FOR 'CH' WITH SIGN EXTENSION         
         BLZ      NEGHW             DAMN-NEGATIVE AW                            
         LI,R3    (TABLSIZ-1)/2     HALFWAY POINT                               
         LI,R8    1**(PWR2-2)        BINARY INCREMENT                           
         CH,R4    OVHWTABL,R3       CHECK WHICH HALF                            
         BE       FOUND              SCORE!!                                    
         BG       UPPER                                                         
         LI,R3    (1**(PWR2-1))-1   LOWER                                       
         B        CMPRHW                                                        
MINUS    SW,R3    R8                MOVE NEGATIVE                               
NXTCMP   SLS,R8   -1                SHIFT POWER OF 2                            
         AI,R8    0                  CHECK IF LAST STEP                         
         BE       LASTCASE            YES                                       
CMPRHW   CH,R4    OVHWTABL,R3         NO-COMPARE WITH TABLE ENTRY               
         BL       MINUS                                                         
         BG       PLUS                                                          
FOUND    LB,R5    OVBYTABL,R3       GET OVERSTRIKE BYTE                         
         B        SETBYTE                                                       
FOUNDNEG LB,R5    NEGBYTBL,R3                                                   
         B        SETBYTE                                                       
UPPER    LI,R3    TABLSIZ-1**(PWR2-1)                                           
         B        CMPRHW                                                        
PLUS     AW,R3    R8                MOVE POSITIVE                               
         B        NXTCMP                                                        
LASTCASE CH,R4    OVHWTABL,R3       LAST CHANCE                                 
         BE       FOUND              OK                                         
         BNE      BADCHAR           NO DICE                                     
NEGHW    LI,R3    NEGHWTSZ          CHECK IN THE                                
         CH,R4    NEGHWTBL,R3        NEGATIVE HALFWORD                          
         BE       FOUNDNEG            TABLE                                     
         BDR,R3   NEGHW+1              -SMALL TABLE-LINEAR SEARCH               
         LW,R3    SAVE312+8         GET LINK (R11)                              
         CI,R3    QQINRET            CHECK IF O-U-T TEST IS RELEVANT            
         BNE      BADCHAR             NO                                        
         AI,R4    X'291C'           CHECK FOR 'OU'-POSSIBLE O-U-T               
         BNE      BADCHAR           NO CHANCE                                   
         BAL,R11  NEXTBYTE           GET NEXT BYTE                              
         CI,R5    8                 BACKSPACE                                   
         BNE      BADCHRM1           NO                                         
         BAL,R11  NEXTBYTE          GET NEXT BYTE                               
         CI,R5    X'E3'             T                                           
         BNE      BADCHAR           NO-BAD CHARACTER                            
OUTFSET  MTW,1    OUTFLAG           YES-SET FLAG                                
         B        BADCHAR           SCAN TO END OF INPUT                        
*                                                                               
*  BAD CHARACTER PROCESSOR  *                                                   
*                                                                               
         LOCAL                                                                  
BADCHRM1 AI,R7    -1                                                            
BADCHAR  CW,R6    BCHAR             CHECK BCHAR COLUMN                          
         BGE      NEXTCOL                                                       
         STW,R6   BCHAR             SET BCHAR FLAG TO LOWER COLUMN              
         B        NEXTCOL            IF INDICATED-CONTINUE LINE SCAN            
*                                                                               
*  MNEMONIC  PROCESSOR     *                                                    
*                                                                               
MNEMONIC MTW,1    MNEMFLG           SET MNEMONIC CHECK FLAG                     
         LI,R5    X'43'             APL %                                       
         B        ORDINARY                                                      
*                                                                               
*  BACKSPACE PROCESSOR      *                                                   
*                                                                               
BACKSP   AI,R6    -2                MOVE BACK 2 (FOR NET OF -1)                 
         BGEZ     NEXTCOL            CHECK UNDERFLOW                            
         LI,R6    -1                  YES-SET TO START ON COL 0                 
         B        NEXTCOL                                                       
*                                                                               
*  TAB   PROCESSOR          *                                                   
*                                                                               
         LOCAL    ADDINT,SETABPOS,TABIND,TABNXT                                 
HTAB     LW,R8    TABPNTR           CHECK IF TABS SET                           
         BEZ      NEXTCOL            NO-QUICK OUT                               
         CI,R8    128               CHECK INDIVIDUAL VS EQUIDISTANT TABS        
         BGE      TABIND             INDIVIDUAL                                 
         LI,R8    -1                EQUIDISTANT-SET LOOP                        
ADDINT   AW,R8    TABPNTR            GET NEXT SETTING                           
         CW,R6    R8                  CHECK POSITION                            
         BGE      ADDINT               NOT YET                                  
SETABPOS LW,R6    R8                NOW!                                        
         B        NEXTCOL                                                       
TABIND   LI,R3    0                 INDIVIDUAL TABS                             
TABNXT   AI,R3    1                  POINT TO NEXT SETTING                      
         LB,R8    TABVALS,R3          GET VALUE                                 
         BEZ      NEXTCOL              QUIT ON ZERO                             
         AI,R8    -1                   OFFSET FOR 0-INDEXING ON IMAGE           
         CW,R6    R8                   CHECK POSITION                           
         BL       SETABPOS          SCORE!                                      
         B        TABNXT               LOOP                                     
*                                                                               
*  ERASERT-ROUTINE USED TO ERASE RIGHT END OF IMAGE AND CORRECT QCNT   *        
*                                                                               
         LOCAL    LOOP,NQUOTE                                                   
ERASERT  LI,R10   BLANK                                                         
         LI,R4    BYSIZIM           SET END OF IMAGE                            
LOOP     LB,R5    IMAGE,R4           GET BYTE                                   
         CI,R5    X'7D'             QUOTE                                       
         BNE      NQUOTE             NO                                         
         MTW,-1   QCNT               YES-DECREMENT COUNT                        
NQUOTE   STB,R10  IMAGE,R4          SET BLANK                                   
         AI,R4    -1                                                            
         CW,R4    R6                CHECK IF COL PASSED                         
         BGE      LOOP               NO-LOOP                                    
         STW,R6   HICOL             SAVE POSITION                               
         STW,R6   EDITCK             FLAG EDIT OPERATION                        
         AI,R6    -1                  SET FOR NEXT ACCESS                       
         CW,R6    BCHAR             CHECK IF BAD CHAR INDICATOR                 
         BG      *R11                SHOULD BE RESET                            
         LI,R10   1000               YES(AT LEAST MAYBE)                        
         STW,R10  BCHAR                                                         
         B       *R11                YES-RETURN                                 
*                                                                               
*  FORMFEED PROCESSOR        *                                                  
*                                                                               
         LOCAL    ATTNAPL,FRMFEED1                                              
FORMFEED LI,R8    LFEED             PROMPT ADDRESS                              
         LI,R9    2                  AND SIZE                                   
         B        FRMFEED1            USE EOTATTN ROUTINE                       
*                                                                               
*  EOTATTN PROCESSOR         *                                                  
*                                                                               
EOTATTN  LI,R8    EOTAPL            PROMPT WORD ADDRESS                         
         LW,R5    TERMTYPE           CHECK IF                                   
         CI,R5    1                   TERMINAL 1                                
         BE       ATTNAPL              YES                                      
         LI,R8    EOTNAPL              NO-NEW PROMPT ADDRESS                    
ATTNAPL  LI,R9    5                 PROMPT SIZE                                 
FRMFEED1 BAL,R11  ERASERT           ERASE BEYOND ATTN                           
         LW,R11   SAVE312+8          RESTORE LINK REGISTER              12-00050
         CI,R11   INPXEQR             CHECK IF 'EXECUTE' CALL           12-00051
         BE       NEXTCOL              YES-NO INPUT PROMPT              12-00052
         LI,R10   0                 BYTE DISPLACEMENT                           
         BAL,R7   CALWROUT           OUTPUT EDIT PROMPT                         
         STW,R10  OUTSIZ            ZERO OUTSIZ                                 
         B        SETCAL             GET NEXT INPUT RECORD                      
*                                                                               
*  INDEX  PROCESSOR          *                                                  
*                                                                               
INDEX    BAL,R11  ERASERT           ERASE BEYOND INDEX                          
         B        NEXTCOL                                                       
*                                                                               
*  IDLE   PROCESSOR                                                             
*                                                                               
IDLEPR   AI,R6    -1                AVOID ADVANCING IMAGE POS                   
         B        NEXTCOL                                                       
*                                                                               
*  NEWLINE PROCESSOR         *                                                  
*                                                                               
         LOCAL    MNEM1,MNEM2,MNEM3,MNEM4,TRY2,MNEM5,TRY1,MNEM6                 
         LOCAL    TRYU,FOUND3,FOUND2,FOUND1,DOLLAR                              
         LOCAL    NWLIN1,QOUT,QBCHAR                                            
NEWLINE  LI,R7    0                                                             
         CW,R6    EDITCK            CHECK FOR ATTN-CR SEQUENCE                  
         BE       QBCHAR             PROBABLY                                   
         STW,R7   EDITCK             NO-RESET EDITCK                            
QBCHAR   LW,R6    BCHAR                                                         
         CI,R6    1000                                                          
         BNE      QOUT              YES-CHECK FOR OUT                           
         MTW,0    MNEMFLG           CHECK FOR POSSIBLE MNEMONIC                 
         BEZ      NWLIN1             NO,THANK GOD                               
SQUEEZER LI,R6    0                  YES,ONE MORE PASS (ENTRY-FOROPEN)          
         LI,R7    0                 PRESET INDEXES FOR PASS                     
MNEM1    LB,R5    IMAGE,R6          GET BYTE                                    
         CI,R5    X'43'              CHECK FOR APL %                            
         BE       MNEM2               YES-CHECK FOR MNEMONIC                    
SETCHAR  STB,R5   IMAGE,R7          SET CHARACTER (MAY OVERLAY ITSELF)          
         AI,R7    1                 UPDATE                                      
         AI,R6    1                  INDEXES                                    
         CW,R6    HICOL                CHECK IF DONE                            
         BL       MNEM1                 NO                                      
         STW,R7   HICOL             CORRECT HICOL FOR MNEMONIC SQUEEZE          
         B        NWLIN1                YES                                     
MNEM2    LI,R3    0                 SET  INDEX                                  
         LI,R10   3                  AND LOOP                                   
MNEM3    AI,R6    1                                                             
         LB,R5    IMAGE,R6                                                      
         STB,R5   R4,R3             FORM  C1,C2,C3,X IN R4                      
         AI,R3    1                                                             
         BDR,R10  MNEM3                                                         
         LW,R5    FFFFFF00          SET MASK FOR COMPARISON                     
         LI,R3    MNEMT3SZ           SET LOOP FOR SEARCH OF 3-CHAR MNEMS        
MNEM4    CS,R4    MNEMT3-1,R3         CHECK                                     
         BG       TRY2                 TOO FAR-TRY 2-CHAR MNEMONICS             
         BE       FOUND3                FOUND!                                  
         BDR,R3   MNEM4                  LOOP                                   
TRY2     AI,R6    -1                BACK UP 1                                   
         SLS,R4   -16               R4=0,0,C1,C2                                
         OR,R4    FFFF0000          SET LEFT HALF FOR 'CH'                      
         LI,R3    MNEMT2SZ          SET LOOP                                    
MNEM5    CH,R4    MNEMT2,R3          SEARCH 2 CHAR MNEMONIC TABLE               
         BG       TRYU                NO CHANCE                                 
         BE       FOUND2               FOUND!                                   
         BDR,R3   MNEM5                 LOOP                                    
TRY1     AI,R6    -1                BACK UP 1                                   
         EOR,R4   FFFF0000          RESET LEFT HALF  TO 0                       
         SLS,R4   -8                R4=0,0,0,C1                                 
         LI,R3    MNEMT1SZ          SET LOOP                                    
MNEM6    CB,R4    MNEMT1,R3          SEARCH SINGLE CHAR MNEMONIC TABLE          
         BG       DOLLAR              NOT A MNEMONIC                            
         BE       FOUND1               FOUND!                                   
         BDR,R3   MNEM6                 LOOP                                    
DOLLAR   AI,R6    -1                BACK UP 1                                   
         LI,R5    X'43'             APL %                                       
         B        SETCHAR           SET CHARACTER                               
TRYU     CLM,R4   UAUZ              CHECK UA  TO UZ                             
         BCS,9    TRY1              NO                                          
         AI,R4    X'1BC0'           YES-FORM LOWER CASE LETTER                  
         LW,R5    R4                                                            
         B        SETCHAR           SET CHARACTER                               
FOUND3   LI,R5    X'FF'             SET MASK                                    
         AND,R5   MNEMT3-1,R3        GET BYTE-MATCH FOR 3-CHAR MNEM.            
         BNEZ     SETCHAR           CHECK IF  %OUT                              
         MTW,1    OUTFLAG            YES                                        
         B        QOUT                TAKE OUT EXIT                             
FOUND2   LB,R5    MNEMC2,R3          GET BYTE-MATCH FOR 2-CHAR MNEM.            
         B        SETCHAR           SET CHARACTER                               
FOUND1   LB,R5    MNEMC1,R3          GET BYTE-MATCH FOR 1-CHAR MNEM.            
         B        SETCHAR           SET CHARACTER                               
NWLIN1   LW,R6    HICOL             NO-NORMAL EXIT                              
         LI,R5    X'15'                                                         
         STB,R5   IMAGE,R6          SET  CR                                     
         LI,R3    BA(IMAGE)                                                     
         AWM,R3   HICOL             ON EXIT, HICOL=BA(CARRIAGE RETURN)          
         LCI      10                                                            
         LM,R3    SAVE312           RESTORE REGISTERS R3-R12                    
         B       *R11               R11 IS LINK                                 
QOUT     MTW,0    OUTFLAG           CHECK FOR OUT                               
         BEZ      BCHNEWL           NO                                          
CRONLY   LI,R6    0                 SET LINE                                    
         STW,R6   HICOL              TO 'CR'                                    
         B        NWLIN1              ONLY                                      
*                                                                               
*  BAD CHARACTER RESOLUTION        *                                            
*                                                                               
BCHNEWL  LI,R8    IDBADCH           = ERROR I.D. FOR 'BAD CHAR'.                
         BAL,R7   CMDERRH           HANDLE LIKE A CMD ERROR.                    
         LW,R6    ON%OFF             CHECK IF OFF-LINE                          
         BEZ      BCONTOFF          YES-QUIT                                    
         LW,R6    BCHAR             GET BAD CHAR                                
         BAL,R11  ERASERT                                                       
         LW,R11   SAVE312+8         RESTORE LINK REGISTER               12-00054
         CI,R11   INPXEQR             CHECK IF 'EXECUTE' CALL           12-00055
         BE       INPXEQBC             YES-DUMP NON-PROMPT PART-LINE    12-00056
         LI,R11   0                                                             
         STW,R11  EDITCK            RESET EDITCK                                
         AI,R6    1                                                             
         LI,R3    IDLE              SET IDLE                                    
         STB,R3   IMAGE,R6           IN IMAGE FOR PROMPT                        
         LW,R3    R6                                                            
         BAL,R12  DUMPLINP            AS A PROMPT-LEAVE IMAGE INTACT            
         LW,R6    ENDIMAGE          RESTORE IMAGE                               
         LI,R5    BLANK                                                         
         STB,R5   IMAGE,R6          REPLACE IDLE WITH BLANK                     
         AI,R6    -1                BACK UP-NEW INPUT APPENDS TO IMAGE          
         LI,R5    0                                                             
         STW,R5   OUTSIZ            RESET TO IGNOR PROMPT                       
         B        SETCAL             RESUME INPUT                               
*                                                                               
* TEXT FOR FIXED PROMPT MESSAGES  *                                             
*                                                                               
LFEED    DATA     X'20160000'       INDEX-IDLE                                  
EOTAPL   DATA     X'20792008',X'16000000'    IX-OR-IX-BS-IDLE                   
EOTNAPL  DATA     X'207C2008',X'16000000'    IX-@-IX-BS-IDLE                    
         PAGE                                                                   
*                                                                               
* PRMTIMAG-ROUTINE TO PROMPT WITH CHARACTERS IN IMAGE                           
*           ON ENTRY,R3=CHAR COUNT                                              
*                                                                               
* PRMTBLNK-ROUTINE TO PROMPT WITH 6 BLANKS                                      
*                                                                               
*                                                                               
* R11-IS LINK                                                                   
*        R3,R9,R12 USED                                                         
*                                                                               
*        SUBROUTINE DUMPLINP USED(USES R12,R3,SAVES ALL OTHERS)                 
*                                                                               
* PROMPT GENERATED ONLY IF ON-LINE (FAKED IF OFF-LINE)                          
*   EXIT TO CONTINUE ON 'HANG UP', AFTER FORCED FUNCT CLOSE IF NECESSARY        
*                                                                               
PRMTBLNK LW,R9    BLANKS            SET BLANKS                                  
         STD,R9   IMAGE              IN BYTES 0-7                               
         LI,R3    6                 OFFSET FOR 'IDLE'                           
PRMTIMAG LW,R9    BREAKFLG          CHECK FOR  HANG-UP                          
         BLZ      HANGUP             YES-QUIT                                   
         LCW,R9   ON%OFF            ON-LINE=-1, OFFLINE=0                       
         AI,R9    1                          0          +1                      
         STW,R9   BREAKFLG          FAKE BREAK IF OFF-LINE (NO PROMPT)          
         LI,R9    X'16'               SET 'IDLE'                                
         STB,R9   IMAGE,R3                                                      
         BAL,R12  DUMPLINP          DUMP LINE WITHOUT CR                        
         LCW,R3   BREAKFLG          CHECK FOR HANGUP                            
         BGZ      BCONTOFF           YES                                        
         AWM,R3   BREAKFLG            NO-RESET BREAK FLAG                       
         B       *R11                RETURN                                     
HANGUP   LI,R14   BCONTOFF          HANG-UP DETECTED ON PROMPT                  
         LW,R13   MODE               CHECK MODE                                 
         BEZ      B4CLOSE             FN OPEN FORCE CLOSE AND QUIT              
         B        BCONTOFF             NO FN OPEN-QUIT                          
         END                                                                    
