       ASB,HEX   ;DC14F - 6/27/76 - 1000 HRS. 
;****  THIS IS THE ROM VERSION  *********** 
; 
;  COMMON EQUATES - CM34 - 6/10/76 - 1315 HRS.
; 
FSTRAM EQU  110400Q   ;FAST RAM LOWER LIMIT 
;***************************************
; KBDCSW - KEYBOARD DATA COMM SWITCHES *
;***************************************
FULDUP EQU  200Q      ;HALF/FULL DUPLEX 
;************************************** 
; KBJMPR - KEYBOARD INTERFACE JUMPERS * 
;************************************** 
; 
;  JUMPERS SENSED AS 0' WHEN INSERTED 
; 
;  ALL JUMPERS ARE NORMALLY INSERTED
; 
CONDIS EQU 001Q     ;CONTROL CODE DISABLE 
;                     (0=DISABLED)
SPLDIS EQU 002Q     ;SPOW LATCH DISABLE 
;                     (0=DISABLED)
LINWRP EQU 004Q     ;COLUMN 80 AUTO CR,LF 
;                     (0=ENABLED) 
PAGSTR EQU 010Q     ;PAGE MODE STRAP
;                     (0=LINE-FIELD MODE) 
LFPOS  EQU 20Q      ;LINE FEED POSITION 
;                     (0 = POSITION LINE FEED 
;                         AT START OF NEXT I/O
;                         READ
;                      1 = PUT LINE FEED AT END 
;                         OF RECORD)
FSTSND EQU 40Q      ;9600 BAUD DATACOM SHIFT
;                     (0=9600 BAUD FOR ESC,E) 
HNDSHK EQU 100Q     ;BLOCK TRANSFER HANDSHAKE 
;                     (0 = FOLLOW DC2SND SETTING
;                      1 = SEND DC2 BEFORE DATA)
DC2SND EQU 200Q 
;                     (0 = SEND DC2 ON ENTER
;                          AND FUNCTION KEY IN
;                          BLOCK MODE 
;                      1 = INHIBIT ALL DC2
;                          HANDSHAKE) 
 
;****************************************** 
; KBJMP2 - SECOND SET OF KEYBOARD JUMPERS * 
;****************************************** 
AUTTRM EQU  1Q        ;AUTO TERMINATE ON "ENTER"
CLRTRM EQU  2Q        ;CLEAR TERMINATOR ON TRANSMI
NOTEST EQU  4Q        ;INHIBIT TERMINAL SELF-TEST 
EDTWRP EQU  10Q       ;INVERT SENSE OF EDIT WRAP
PRNTAL EQU  20Q       ;SEND ALL CODES TO PRINTER
DCJMP0 EQU  200Q      ;DATA COMM JUMPER 
;*****************************************
; KBJMP3 - THIRD SET OF KEYBOARD JUMPERS *
;*****************************************
DCJMP1 EQU  1Q        ;DATA COMM JUMPERS
DCJMP2 EQU  2Q              ;.
DCJMP3 EQU  4Q              ;.
DCJMP4 EQU  10Q             ;.
NODCST EQU  20Q       ;INHIBIT DATA COMM SELF-TEST
;                       (0 = DISABLED)
SETCH  EQU  40Q       ;TURN ON "CH" CONTROL LINE
;                       (0 = OFF, 1 = ON) 
CHEKCC EQU  100Q      ;MONITOR CC CONTROL LINE
;                       (1 = ENABLED) 
FRCPTY EQU  200Q      ;FORCE PARITY ON/NO IN CHECK
;                       (1 = ENABLED) 
;************************ 
; CMFLGS - COMMON FLAGS * 
;************************ 
BLKTRG EQU  1Q        ;BLOCK TRANSFER TRIGGER 
INSWRP EQU  2Q        ;INSERT WITH WRAP AROUND
FRCRST EQU  4Q        ;FORCE FULL TERMINAL RESET
DEFSKY EQU  10Q       ;DEFINE SOFT KEY MODE ENABLE
REMSET EQU  20Q       ;REMOTE MODE ENABLED
RCVMDE EQU  40Q       ;TERMINAL IN RECEIVE MODE 
;***********************
; ERRFLG - ERROR FLAGS *
;***********************
DCMERR EQU  1Q        ;DATACOM (1 = ERROR)
TESTOK EQU  2Q        ;SELF-TEST (0 = ERROR)
LDRCHK EQU  4Q        ;LOADER CHECKSUM (0 = ERROR)
;************************** 
; INTFLG - INTERRUPT FLAG * 
;************************** 
TMRINT EQU  3         ;TIMER INTERRUPT
 
;***********************************
; PRCCTL - PROCESSOR CONTROL FLAGS *
;***********************************
TMIACK EQU  0Q        ;ACKNOWLEDGE TIMER INTERRUPT
;                       (BIT 1 OFF) 
TMRON  EQU  1Q        ;SET TIMER ON 
TMIEN  EQU  2Q        ;RE-ENABLE TIMER INTERRUPT
DCIOFF EQU  20Q       ;DISABLE DATA COMM INTERRUPT
TMIOFF EQU  40Q       ;DISABLE TIMER INTERRUPTS 
POLL   EQU  100Q      ;POLL CTU INTERRUPTS
;V*V*V*V*  SET TO ZERO FOR ROM VERSION  *V*V*V*V* 
SETROM EQU  200Q      ;DISABLE (1)/ENABLE (0) ROM 
;*********************************
; MDFLG1 - TERMINAL MODE FLAGS 1 *
;*********************************
DSPFNC EQU  1Q        ;DISPLAY FUNCTIONS ENABLED
INSCHR EQU  2Q        ;INSERT CHARACTER ENABLED 
MEMLOK EQU  4Q        ;MEMORY LOCK ENABLED
FORMAT EQU  10Q       ;FORMAT MODE ENABLED
EDIT   EQU  20Q       ;EDIT MODE ENABLED
SELECT EQU  40Q       ;SELECT MODE ENABLED
RECORD EQU  100Q      ;RECORD MODE ENABLED
FORGN  EQU  200Q      ;FOREIGN MODE ENABLED 
;*********************************
; MDFLG2 - TERMINAL MODE FLAGS 2 *
;*********************************
CAPSLK EQU  1Q        ;CAPS LOCK ENABLED
BLKMDE EQU  2Q        ;BLOCK MODE ENABLED 
AUTOLF EQU  4Q        ;AUTO LF ENABLED
REMOTE EQU  10Q       ;REMOTE ENABLED 
WBSR   EQU  40Q       ;WRITE-BACKSPACE-READ MODE
;********************************************** 
; RADIX - BASE OF INPUT PARAMETER FOR ESC SEQ * 
;********************************************** 
DECRDX EQU  10        ;DECIMAL NUMBERS
OCTRDX EQU  8         ;OCTAL NUMBERS
 
;*******************
; COMMON VARIABLES *
;*******************
INTVEC EQU  FSTRAM+145Q  ;CENTRAL INTERRUPT VECTOR
SCNVEC EQU  INTVEC+3  ;FOREIGN TERMINAL DISPLY SCA
; 
COMMON EQU  177777Q   ;UPPER LIMIT OF COMMON AREA 
CMBASE EQU  COMMON/256  ;MSB OF COMMON ADDRESSES
CMSTOR EQU  CMBASE*256  ;MSB ADJUSTMENT FACTOR
; 
DISPST EQU  COMMON-1  ;DISPLAY REFRESH START PTR
TRMTYP EQU  DISPST-1  ;TERMINAL TYPE NUMBER 
KBDCSW EQU  TRMTYP-1  ;KEYBOARD DATACOM SWITCHES
KBJMPR EQU  KBDCSW-1  ;KEYBOARD STRAPS
KBJMP2 EQU  KBJMPR-1    ;SET 2
KBJMP3 EQU  KBJMP2-1    ;SET 3
CMFLGS EQU  KBJMP3-1  ;COMMON FLAGS 
ERRFLG EQU  CMFLGS-1  ;ERROR FLAGS
INTFLG EQU  ERRFLG-1  ;INTERRUPT FLAG 
PRCCTL EQU  INTFLG-1  ;PROCESSOR CONTROL FLAGS
MDFLG1 EQU  PRCCTL-1  ;TERMINAL MODE FLAGS 1
MDFLG2 EQU  MDFLG1-1    ;AND 2
MSGPT1 EQU  MDFLG2-2  ;MESSAGE POINTERS 
MSGPT2 EQU  MSGPT1-2       ;. 
MSGPT3 EQU  MSGPT2-2       ;. 
MSGPT4 EQU  MSGPT3-2       ;. 
MSGPT5 EQU  MSGPT4-2       ;. 
MSGPT6 EQU  MSGPT5-2       ;. 
MSGPT7 EQU  MSGPT6-2       ;. 
MSGPT8 EQU  MSGPT7-2       ;. 
CTIVEC EQU  MSGPT8-2  ;CTU INTERRUPT VECTOR 
CTIJMP EQU  CTIVEC-1  ;JUMP CODE FOR VECTOR 
IODATA EQU  CTIJMP-2  ;ESQ SEQ PARM ACCUMULATOR 
IOCSGN EQU  IODATA-1  ;SIGN FOR PARAMETER 
IOPSGN EQU  IOCSGN-1  ;PARAMETER SIGN 
PARM1  EQU  IOPSGN-1  ;ESCAPE SEQUENCE PARAMETERS 
PARM2  EQU  PARM1-1        ;. 
PARM3  EQU  PARM2-1        ;. 
PARM4  EQU  PARM3-1        ;. 
PARM5  EQU  PARM4-1        ;. 
PARM6  EQU  PARM5-2        ;. 
RADIX  EQU  PARM6-1   ;RADIX OF PARAMETERS
RNGTA  EQU  RADIX-2   ;CHAR FUNCTION TABLE ADDRESS
ESCFLG EQU  RNGTA-1   ;ESCAPE SEQUENCE FLAG 
;                       = 0, NOT IN ESCAPE SEQ
;                       # 0, ESC SEQ IN PROGRESS
RSTTMR EQU  ESCFLG-1  ;SOFT RESET TIMER 
; * * * * * * * * * * * * * * * * * * * * * * * * 
;  END OF COMMON EQUATES                        * 
;^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^* 
 
;*******************************
; DCSTAT - DATACOM STATUS BITS *
;*******************************
DCDP   EQU 1Q       ;DATA PRESENT 
DCTBE  EQU 002Q     ;TRANSMIT BUFFER EMPTY
DCOE   EQU 004Q     ;OVERRUN ERROR
DCPE   EQU 010Q     ;PARITY ERROR 
; 
; 
;  THE FOLLOWING ARE INTERPRETED AS 0 = ON AND
;    1 = OFF
; 
DCCF   EQU  20Q       ;CF - RECEIVED CARRIER
DCCB   EQU  40Q       ;CB - CLEAR TO SEND 
DCSB   EQU  100Q      ;SB - SECONDARY RECEIVED DAT
; 
DCCC   EQU  200Q      ;CC - DATA SET READY? 
; 
;*************************
; DCFLGS - DATACOM FLAGS *
;*************************
DCCA   EQU  1         ;REQUEST TO SEND (0 = SET)
TRNMOD EQU  2         ;TRANSPARENT MODE 
BINMOD EQU  4         ;BINARY MODE
GOBIN  EQU  10Q       ;GO TO BINARY MODE ON ENQ-AC
FB9600 EQU  20Q       ;FAST BINARY MODE 
MCMOD  EQU  40Q       ;MAIN CHANNEL (0 = ENABLED) 
SPECHO EQU  100Q      ;ECHO SUPPRESS (1 = ENABLED)
FORPAR EQU  200Q      ;FORCE PARITY MODE
 
;*********************
; I/O MODULE EQUATES *
;*********************
IOBASE EQU 200Q     ;I/O ADDRESS MSB'S
PROCSR EQU  160Q      ;PROCESSOR PORT 
;***********
; KEYBOARD *
;***********
IOKB   EQU  (3Q+IOBASE)*256;MODULE 11 BASE ADDRESS
IOKBLD EQU  IOKB+0Q  ;SET KEYBOARD LED'S
;********** 
; DATACOM * 
;********** 
IODC   EQU  (1Q+IOBASE)*256;MODULE 10 BASE ADDRESS
; 
;  INPUT ADDRESSES
; 
IODCDI EQU  IODC+0Q   ;DATACOM DATA IN
IODCST EQU  IODC+40Q  ;DATACOM STATUS IN
IODCS2 EQU  IODC+41Q  ;STATUS W/TBE = THRE AND TRE
IODCPC EQU  IODC+100Q  ;DATACOM STRAPS IN 
DCCTL2 EQU  IODC+140Q  ;ALTERNATE DATACOM CONTROL 
; 
;  OUTPUT ADDRESSES 
; 
IODCCT EQU  IODC+100Q  ;DATACOM CONTROL OUT 
IODCDO EQU  IODC+140Q  ;DATACOM DATA OUT
; 
;  DATACOM CONTROL BITS 
; 
B9600  EQU  16Q       ;9600 BAUD
DCSA   EQU  100Q      ;TURN ON SECONDARY TRANSMIT 
DCOP   EQU  0         ;ODD PARITY 
DCEP   EQU  20Q       ;EVEN PARITY
DCNP   EQU  40Q       ;NO PARITY
; 
CDOFF  EQU  10Q       ;TURN OFF CD (USE W/DCCTL2) 
DCCH   EQU  200Q      ;CH BIT IN CONTROL
BAUDPT EQU  076Q      ;BAUD RATE/PARITY MASK
 
; 
;  KEYBOARD ENTRY VECTOR POINTERS 
; 
ZKBBAS EQU  44000Q    ;KEYBOARD START ADDRESS 
ZINIKB EQU  ZKBBAS+2  ;INITIALIZE KEYBOARD
ZGETKY EQU  ZINIKB+3  ;GET KEYBOARD KEY 
ZKBCTL EQU  ZGETKY+3  ;PERFORM KEYBOARD CONTROL 
ZKBMON EQU  ZKBCTL+3  ;MONITOR KEYBOARD 
ZSTMD1 EQU  ZKBMON+3  ;SET MODE 1 FLAGS 
ZCLMD1 EQU  ZSTMD1+3  ;CLEAR MODE 1 FLAGS 
ZBELL  EQU  ZCLMD1+3  ;SOUND THE BELL 
ZSTXMT EQU  ZBELL+3   ;SET TRANSMIT LED 
ZCLXMT EQU  ZSTXMT+3  ;CLEAR TRANSMIT LED 
 
;************************ 
; MISCELLANEOUS EQUATES * 
;************************ 
JMP    EQU  303Q      ;"JMP" CODE 
;************************** 
; ASCII CHARACTER EQUATES * 
;************************** 
ANULL  EQU  0Q        ;NULL 
SOH    EQU  1Q        ;START OF HEADER
STX    EQU  2Q        ;START OF TEXT
ETX    EQU  3Q        ;END OF TEXT
EOT    EQU  4Q        ;END OF TRANSMISSION
LF     EQU  12Q       ;LINE FEED
CR     EQU  15Q       ;CARRIAGE RETURN
ENQ    EQU 5Q 
ACK    EQU 6Q 
DC2    EQU  22Q       ;DEVICE CNTL 2
ACAN   EQU  30Q       ;CANCEL LINE
RS     EQU  36Q       ;RECORD SEPARATOR 
ADEL   EQU  177Q      ;DELETE (RUBOUT)
;************************** 
; DISPLAY CONTROL EQUATES * 
;************************** 
NORMAL EQU  200Q      ;START NORMAL VIDEO 
INVRS  EQU  202Q      ;START INVERSE VIDEO
EOL    EQU  314Q      ;END OF LINE FLAG 
EOP    EQU  316Q      ;END OF PAGE FLAG 
;************************** 
; DATACOM LOCAL VARIABLES * 
;************************** 
DCSTOR EQU  FSTRAM+300Q 
DCBASE EQU  DCSTOR/256
DCSTAT EQU  DCSTOR-1  ;DATACOM STATUS BITS
DCBPTR EQU  DCSTAT-2  ;DATACOM BUFFER UNLOAD PTR
DCSPTR EQU  DCBPTR-2  ;DATACOM LOAD POINTER 
DCBFBG EQU  DCSPTR-2  ;START ADDR OF DATACOM BUFFE
DCFLGS EQU  DCBFBG-1  ;CONTAINS FOLLOWING FLAGS:
DCMVEC EQU  DCFLGS-2  ;DATACOM MONITOR VECTOR 
DCMJMP EQU  DCMVEC-1  ;JUMP CODE FOR VECTOR 
XMTDLY EQU  DCMJMP-1  ;LIMIT FOR XMIT TURNAROUND
DCDLAY EQU  XMTDLY-1  ;DELAY FOR SIGNAL SETTLING
DCTEX  EQU  DCDLAY-2  ;TURNAROUND EXIT ADDRESS
TPARIT EQU  DCTEX-1   ;SELF TEST, PARITY
TMOCNT EQU  TPARIT-1  ;SELF TEST, TIME OUT COUNTER
FPMASK EQU  TMOCNT-1   ;FORCE PARITY MASK 
ENDCHR EQU  FPMASK-1  ;END OF DATA CHAR FOR MC
DCCT   EQU  ENDCHR-1  ;CONTROL WD FOR CH,CA,NP
; 
DCBFSZ EQU  96        ;DATACOM BUFFER SIZE
GPASYC EQU  200Q      ;GENARAL PURPOSE ASYNC FLAG 
 
; 
;  NEW STRAPPING OPTIONS WHEN 202C MAIN CHANNEL 
;    PROTOCOL IS DESIRED.  THESE STRAPS ARE 
;    AVAILABLE FROM THE NEW KEYBOARD I/F AND
;    ARE SWITCHES R - Z  WHICH ARE CURRENTLY
;    NOT USED BY THE FIRMWARE FOR DATACOM.
; 
SBSTRP EQU 200Q ;(R) 0 = ENABLE CIRCUIT ASSURANCE 
;                       (SB)
;                   1 = DISABLE CIRCUIT ASSURANCE 
; 
STXSTP EQU 1Q   ;(S) 0 = USE STX FOR STRT OF DATA 
;                   1 = NO START OF DATA CHAR 
; 
ETXSTP EQU 2Q   ;(T) 0 = USE EOT FOR END OF DATA
;                   1 = USE ETX FOR END OF DATA 
; 
; 
MNCHAN EQU 3Q       ;00 = NON-MAIN CHANNEL PROTCL 
;                   01 = MAIN CHNL W/O SD,ED = EOT
;                   10 = MAIN CHNL W/STX AS SD, 
;                   11 = MAIN CHNL W/ETX AS ED
; 
CBKSTP EQU 4Q   ;(U) 0 = ENABLE CPU BREAK ON SB 
;                   1 = DISABLE CPU BREAK 
; 
CFSTRP EQU 10Q  ;(V) 0 = ENABLE CF DETECT 
;                   1 = DISABLE CF DETECT 
; 
;NODCST EQ 20B  (W) 0 = ENABLE DC SELF TEST 
;                   1 = DISABLE DC SELF TEST
; 
;SETCH EQU 40B  (X) 0 = SET CH OFF
;                   1 = SET CH ON 
; 
;CHEKCC EQ 100B (Y) 0 = USE CB FOR XMIT LED 
;                   1 = USE CC FOR XMIT LED 
; 
;FRCPTY EQ 200B (Z) 0 = DISABLE FORCE PARITY
;                   1 = ENABLE FORCE PARITY 
; 
; 
; 
 
       ORG  50000Q    ;START IN ITS OWN BLOCK 
; 
       DB   'P'     ;VALID ROM ID 
       DB   50000Q/256
TRIGGR:DB   021Q      ;DC1 FOR TRANSFER TRIGGER 
RECSEP:DB   037Q      ;US FOR RECORD SEPARATOR
BLKTRM:DB   036Q      ;RS FOR BLOCK TERMINATOR
DCJMSK:DB   003Q      ;DATA COMM JUMPER ALTER 
;                       INHIBIT MASK - SET TO 1 
;                       IN APPROPRIATE BIT (0-7)
;                       TO INHIBIT ALTERATION OF
;                       JUMPERS S-Z BY ESCAPE 
;                       SEQUENCE
;                       SET TO INHIBIT S,T
DCJMK2:DB   000Q      ;STRAP R
       DB   00Q 
; 
;  DATACOM ENTRY VECTORS
; 
       JMP  INITDC   ;INITIALIZE DATACOM
       JMP  INI2DC   ;INITIALIZATION CONTINUATOR
       JMP  DCMJMP    ;GO TO MONITOR ROUTINE
       JMP  DCCTL     ;PERFORM CONTROL FUNCTIONS
       JMP  DCTST     ;DATACOOM SELF TEST 
       JMP  GETDC     ;GET A DATACOM CHARACTER
       JMP  PUTDC     ;OUTPUT A CHARACTER TO DATAC
       JMP  GETBIN    ;GET A BINARY BYTE
       XRA  A 
       RET
       DB   0Q        ;NOOP START BINARY ROUTINE
       JMP  TRMBIN    ;TERMINATE BINARY OUTPUT
; 
;  DATACOM CONTROL CALL CODES 
; 
CLRTRG EQU  0         ;CLEAR BLOCK TRANSFER TRIGGE
SETTRG EQU  1         ;SET BLOCK TRANSFER TRIGGER 
RSETDC EQU  2         ;RESET DATACOM
SETREM EQU  3         ;SET REMOTE MODE
SETLCL EQU  4         ;SET LOCAL MODE 
PUTBRK EQU  5         ;OUTPUT BREAK SIGNAL
DISCNT EQU  6         ;MODEM DISCONNECT 
ENDBLK EQU  7         ;SEND ED IF MAIN CHANNEL
SETMON EQU  8         ;ENTER MONITOR MODE 
SETNRM EQU  9         ;ENTER NORMAL MODE
PROMPT EQU  13        ;SEND DC2 PROMPT
 
; 
;*******************************
; DATACOM INTERRUPT PROCESSING *
;*******************************
DCINTR EQU $
       PUSH PSW       ;SAVE A,FLAGS 
       PUSH B         ;SAVE B,C 
       LDA  IODCST    ;GET DATA COMM STATUS 
       MOV  B,A       ;SAVE STATUS IN B 
       ANI  DCDP      ;DATA PRESENT?
       JZ   INT170    ;NO - EXIT
       PUSH H         ;YES - SAVE H,L 
       LXI  H,IODCDI  ;GET DATA FROM DATA COMM
       MOV  C,M         ;INTO C-REGISTER
       LDA  DCFLGS    ;CURRENT MODE?
       MOV  L,A       ;SAVE DCFLGS
       ANI  TRNMOD+BINMOD 
       JNZ  INT020    ;TRANSPARENT OR BINARY - JUM
       MOV  A,C       ;ASCII - HANDLE PARITY
       ANI 177Q     ;REMOVE PARITY BIT
       JZ  INT160   ;RETURN IF NULL 
       CPI ADEL 
       JZ  INT160   ;IGNORE RUBOUTS 
       MOV  A,B     ;GET PARITY BIT 
       ANI  DCPE    ;PARITY ERROR?
       JZ   INT020  ;NO JMP 
       MOV  A,L     ;GET DCFLGS 
       ANI  FORPAR  ;IS FORCE PARITY IN EFFECT? 
       JZ   INT050    ;NO - JMP PE ERROR
INT020 EQU  $         ;CHECK FOR BUFFER OVERWRITE 
       MOV  A,B       ;RECALL STATUS
       ANI  DCOE      ;OVERWRITE? 
       JZ   INT100    ;NO - STORE CHAR
;************************************************ 
; DATA COMM ERROR - STORE ALL ONES AND SET FLAG * 
;************************************************ 
INT050 EQU  $         ;DATACOM ERROR
       MVI C,377Q   ;STORE ALL ONES 
       LXI  H,ERRFLG  ;SET ERROR FLAG 
       MOV  A,M 
       ORI  DCMERR
       MOV  M,A 
 
;************************************** 
; STORE CHARACTER IN DATA COMM BUFFER * 
;************************************** 
INT100 EQU $
       LHLD DCSPTR    ;GET THE LOAD POINTER 
       LDA  DCBFBG    ;GET LSB OF BUFFER START ADD
       CMP  L         ;REACHED START OF BUFFER? 
       JNZ  INT130    ;NO - STORE THE CHARACTER 
       MOV  A,L       ;YES - SET TO BUFFER END + 1
       ADI  DCBFSZ
       MOV  L,A 
       MOV  A,H 
       ACI  0 
       MOV  H,A 
; 
INT130 EQU  $ 
       DCX  H         ;DECREMENT TO NEXT LOCATION 
       SHLD DCSPTR    ;STORE THE NEW POINTER VALUE
       LDA  DCBPTR    ;FETCH THE UNLOAD POINTER 
       CMP  L         ;BUFFER OVERFLOW? 
       JZ   INT050    ;YES - STORE ALL ONES 
       MOV  M,C       ;NO - STORE THE NEW CHARACTE
;*******
; EXIT *
;*******
INT160 EQU $
       POP H        ;RESTORE REGISTERS AND
INT170 EQU  $ 
       POP B          ;PROCESSOR STATUS 
       POP PSW
       EI           ;RE-ENABLE INTERRUPTS 
       RET          ;RETURN 
 
; 
; * * * * * * * * * * * * * * * * * * * * * * 
; 
;  PUTDC - DATACOM OUTPUT ROUTINE 
; 
;      ENTRY:  A = CHAR TO BE OUTPUT
;                NC - NORMAL CHAR 
;                C  - LAST CHAR IN BLOCK
; 
;      EXIT :  A DESTROYED
;              NC - NO ERRORS DETECTED
;                Z - CHARACTER ACCEPTED 
;                NZ - WAIT
;              C - DATACOM ERROR
;                Z - TRANSMIT MODE, NO ERROR MSG
; 
PUTDC  EQU  $ 
       PUSH H 
       MOV  L,A       ;SAVE CHAR IN L 
       LDA  DCCT      ;READ CONTROL WD
       MOV  H,A       ;SAVE CONTROL IN H
       LDA  DCFLGS    ;READ FLAGS 
       RRC            ;TERMINAL IN RECEIVE? 
       JNC  PDC004    ;NO, JMP
       LXI  H,ERRFLG
       MOV  A,M 
       ORI  DCMERR
       MOV  M,A 
       POP  H 
       SUB  A 
       STC
       RET            ;C,Z => ERROR, NO MESSAGE 
PDC004 EQU  $ 
       ANI  FB9600-GOBIN  ;FASTBIN ?
       MVI  A,B9600+DCNP  ;SET FASTBIN MODE 
       JNZ  PDC005    ;YES, JUMP
       LDA  KBDCSW    ;READ SWITCHES
       ANI  BAUDPT    ;CLEAR H/F AND CA BITS
PDC005 EQU  $ 
       ORA  H         ;SET COMMAND WORD 
       STA  IODCCT  ;OUTPUT COMMAND WORD TO DC
       LDA IODCST  ;INPUT DATACOM STATUS
       ANI DCTBE    ;IS TRANSMIT BUFFER EMPTY?
       JNZ  PDC020   ;YES, GO OUTPUT THE CHAR 
       PUSH B 
       PUSH D 
       CALL DCMON   ;AVOID EXTERNAL HANG
       POP  D 
       POP  B 
       POP  H 
       SUB  A 
       INR  A 
       RET            ;NC,NZ => WAIT
PDC020 EQU  $         ;OUTPUT CHARACTER 
       LDA  FPMASK    ;READ FORCE PARITY MASK 
       ORA  L         ;OR WITH CHAR 
       STA  IODCDO    ;OUTPUT THE CHAR
       LDA  DCFLGS    ;NOT BINARY/, 
       MOV  H,A       ;SAVE FLAGS 
       ANI  BINMOD+MCMOD   ;AND MC ?
       JZ   PDC030    ;YES, 
PDC025 EQU  $ 
;                    NO, RETURN => NC,Z 
       POP  H 
       CMP  A 
       RET
PDC030 EQU  $ 
       LDA  ENDCHR    ;IS CHAR ED CHAR? 
       CMP  L 
       JZ   PDC070    ;YES, JMP 
       MOV  A,H       ;RECALL DCFLGS
       ANI  TRNMOD    ;TRANSPARENT? 
       JNZ  PDC025    ;RETURN ON TRANSPARENT MODE 
       MOV  A,L       ;IS IT LAST CHAR OF BLOCK?
       CPI  ACK       ;CHAR ACK?
       JZ   PDC060    ;YES, RESPOND OUT 
       LDA  KBJMPR    ;FETCH KEYBOARD JUMPER A-H
       ANI  PAGSTR    ;PAGE MODE? 
       JNZ  PDC040    ;YES, CHECK FOR DC2 OR RS 
PDC035 EQU  $ 
       MOV  A,L       ;NO, CHECK FOR CR OR LF 
       CPI  CR        ;IS IT CR?
       JZ   PDC050    ;YES, CHK TO SEND END OF DAT
       CPI  LF        ;IS IT LF?
       JZ   PDC055    ;YES, CHK TO SEND END OF DAT
       POP  H 
       CMP  A         ;NONE OF THE ABOVE, RETURN
       RET
PDC040 EQU  $ 
       MOV  A,L 
       CPI  DC2       ;IS IT DC2? 
       JZ   PDC060    ;YES, SEND END OF DATA
       LDA  MDFLG2    ;GET MODE FLAGS 
       ANI  BLKMDE    ;ARE WE IN BLOCK MODE?
       JZ   PDC035    ;NO - 
       MOV  A,L       ;RESTORE CHAR 
       CPI  RS        ;IS IT RS?
       JZ   PDC060    ;YES, SEND END OF DATA
       POP  H 
       CMP  A         ;NONE OF THE ABOVE, RETURN
       RET
PDC050 EQU  $ 
       LDA  MDFLG2    ;AUTO LF KEY UP?
       ANI  AUTOLF
       JZ   PDC060    ;YES, SEND END OF DATA
PDC052:POP  H 
       CMP  A 
       RET
PDC055 EQU  $ 
       LDA  MDFLG2    ;AUTO LF KEY DOWN?
       ANI  AUTOLF
       JZ   PDC052    ;NO, RETURN 
PDC060 EQU  $ 
       LDA  ENDCHR    ;GET END OF DATA CHAR 
       CALL PUTDC       ;AND TRANSMIT 
       JC   PDC060
       JNZ  PDC060
       POP  H 
       RET
PDC070 EQU  $ 
       MVI  A,ADEL    ;ALLOW ENOUGH TIME TO MAKE
       ORA  A 
       CALL PUTDC       ;SURE END OF DATA HAS 
       JC   PDC070      ;BEEN TRANSMITTED 
       JNZ  PDC070
PDC080:MVI  A,ADEL
       CALL PUTDC 
       JC   PDC080
       JNZ  PDC080
       PUSH B 
       CALL DCM110    ;GO TO RECEIVE STATE
       POP  B 
       POP  H 
       XRA  A 
       RET
 
; 
; * * * * * * * * * * * * * * * * * * * * * * * * 
; 
;  STRTBN - SET BINARY OUTPUT MODE
; 
;      ENTRY:  DON'T CARE 
; 
;      EXIT :  DON'T CARE 
; 
STRTBN EQU  $ 
STB010 EQU  $ 
       LDA  IODCST    ;READ DC STATUS 
       ANI  DCTBE     ;XMIT BUFF EMPTY? 
       JZ   STB010    ;NO, WAIT 
       LDA  DCCT      ;READ CONTROL WD
       ORI  DCNP      ;SET NO PARITY
       STA  DCCT      ;SET NEW CONTROL WD 
       XRA  A         ;SET RETURN INDICATORS
       STA  FPMASK    ;CLEAR FORCE PARITY 
       RET
 
; 
;  INITDC - INITIALIZE DATACOM
; 
INITDC EQU $
       LXI  B,DCBFSZ  ;SET BUFFER REQUIREMENTS
       RET            ;RETURN TO GET BUFFER 
; 
;  DATACOM INITIALIZATION CONTINUATOR 
; 
INI2DC EQU  $ 
       XCHG           ;PUT BUFFER START IN H AND L
       SHLD DCBFBG    ;STORE BUFFER START ADDRESS 
RSTDCB EQU  $ 
       LDA  IODCPC    ;READ GP DC PROG. STRAPS
       ANI  GPASYC    ;GP ASYNC BOARD IN? 
       LDA  KBJMP3    ;GET STRAPS FOR 202 PRTCL 
       MOV  H,A           ;OPTIONS
       JNZ  RST005    ;YES GP CARD IN 
       ANI  377Q-CHEKCC ;NO, INHIBIT CC LED MONITO
       STA  KBJMP3    ;STORE STRAPS SETTINGS
RST005:ANI  ETXSTP    ;USE ETX? 
       MVI  A,ETX     ;USE ETX
       JNZ  RST006    ;YES
       MVI  A,EOT     ;USE EOT
RST006 EQU  $ 
       STA  ENDCHR    ;STORE ED CHAR
       MOV  A,H       ;RESTORE JMPERS 
       ANI  SETCH     ;IS CH SET? 
       MVI  A,DCCH    ;SET CH OFF 
       JZ   RST007    ;NO 
       XRA  A         ;SET CH ON
RST007 EQU  $ 
       STA  DCCT      ;SET CONTROL WORD 
       MOV  A,H       ;RESTORE JUMPERS
RSTSRM EQU  $ 
       ANI  MNCHAN    ;MAIN CHANNEL?
       MVI  L,0 
       JNZ  RST010    ;YES, 
       MVI  L,MCMOD   ;SET NOT MAIN CHANNEL 
RST010:MOV  A,H       ;RESTORE JUMPERS
       ANI  FRCPTY    ;SET FORCE PARITY 
       STA  FPMASK
RST020:ORA  L         ;SET FP AND MC
       STA  DCFLGS
       LDA  DCCT      ;READ CONTROL WD
       ANI  DCCH      ;CLEAR EXCEPT CH
       STA  DCCT      ;RESTORE
       MOV  H,A       ;SAVE DCCT
       LDA  KBDCSW    ;READ DC SWITCHES 
       ANI  BAUDPT    ;MASK OUT H/F 
       ORA  H         ;SET CONTROL WORD 
       STA  IODCCT    ;OUTPUT DC CONTROLS 
       MVI  A,JMP     ;SET JUMP OP CODE 
       STA  DCMJMP    ;STORE OP 
       LXI  H,DCMON   ;SET INITIAL DATA COMM
       SHLD DCMVEC      ;MONITOR VECTOR 
       LDA  IODCST    ;SET INITIAL DATA COMM STATU
       STA  DCSTAT
       MVI  A,1       ;SET THE BLOCK TRANSFER 
       CALL DCCTL       ;TRIGGER
RSTDC1 EQU $
       LHLD DCBFBG    ;SET LOAD AND UNLOAD POINTER
       SHLD DCSPTR      ;EQUAL TO EACH OTHER
       SHLD DCBPTR
       RET
 
; 
; * * * * * * * * * * * * * * * * * * * * * * * 
; 
;  GETDC - GET DATA (7 BITS) FROM DATA COM
; 
;      ENTRY:  DON'T CARE 
; 
;      EXIT :  NC - NO ERRORS DETECTED
;                Z - CHARACTER AVAILABLE
;                  A = CHARACTER
;                NZ - WAIT
;                  A DESTROYED
;              C - DATACOM ERROR
;                A DESTROYED
;                Z - NO ERROR MESSAGE 
;                NZ - DISPLAY ERROR MESSAGE 
;                  B,C -> ERROR MESSAGE 
; 
GETDC  EQU  $ 
       PUSH H 
       LXI  H,DCFLGS  ;FETCH DATACOM FLAGS
       DI 
       MOV  A,M 
       ANI  377Q-BINMOD  ;TURN OFF BINARY 
       MOV  M,A 
       ANI  FORPAR    ;FORCE PARITY ON? 
       STA  FPMASK    ;SET FPMASK 
       MOV  A,M       ;RESTORE A
GDC001 EQU  $ 
       EI 
       ANI  SPECHO+TRNMOD ;IGNORE ECHO FROM DATACO
       CPI  SPECHO    ;IS SPECHO ON WITHOUT TRANS?
       JNZ  GDC005    ;NO CHECK FOR CHAR
       MOV  A,M        ;GET FLAGS AGAIN 
       ANI  BINMOD+DCCA 
       CPI  DCCA      ;NOT BIN AND REC ?
       JNZ  GDC002    ;NO - RETURN WAIT STATUS
       LDA  KBJMP3    ;GET SWITCH SETTINGS
       ANI  STXSTP    ;TEST FOR SD CHAR 
       JNZ  GDC002    ;NO CONTINUE WAIT 
       CALL GDC004    ;YES - CHK FOR STRT OF DATA 
       JC   GDC002    ;NO CHAR, CONTINUE WAIT 
       JNZ  GDC002    ;NO CHAR, CONTINUE WAIT 
       CPI  STX       ;WAS CHR STX ?
       JNZ  GDC002    ;NO, CONTINUE WAITING 
       LXI  H,DCFLGS  ;YES,TURN OFF ECHO SUPPRESS 
       DI 
       MOV  A,M 
       ANI  377Q-SPECHO 
       MOV  M,A 
       EI 
; 
;  NO DATA - EXIT WAIT
; 
GDC002 EQU  $ 
       POP  H         ;RESTORE H,L
       ORI  1         ;SET NC,NZ
       EI 
       RET            ;RETURN WAIT
GDC004 EQU  $ 
       PUSH H         ;SAVE H AND L 
GDC005 EQU  $ 
       DI 
       LHLD DCBPTR    ;GET THE UNLOAD ADDRESS 
       LDA  DCSPTR    ;GET THE LSB OF THE LOAD PTR
       CMP  L         ;ANY CHARACTERS IN BUFFER?
       JNZ  GDC007    ;YES - GET ONE
;                     NO - CHECK FOR DATA COMM
       LDA  IODCST      ;DATA IN
       ANI  DCDP      ;DATA PRESENT?
       JZ   GDC002    ;NO - EXIT
       CALL DCINTR    ;YES - GET THE CHARACTER
       EI             ;RE-ENABLE INTERRUPTS 
       JMP  GDC005    ;GET CHAR FROM INPUT BUFFER 
 
; 
;  GET CHARACTER FROM INPUT BUFFER
; 
GDC007 EQU  $ 
       LDA  DCBFBG    ;FETCH LSB OF BUFFER START
       CMP  L         ;AT BEGINNING OF BUFFER?
       JNZ  GDC008    ;NO - GET THE NEXT CHARACTER
       ADI  DCBFSZ    ;YES - WRAP AROUND TO END OF
       MOV  L,A         ;BUFFER 
       MOV  A,H 
       ACI  0 
       MOV  H,A 
; 
GDC008 EQU  $ 
       DCX  H         ;DECREMENT TO NEXT CHARACTER
       SHLD DCBPTR    ;STORE NEW POINTER
       EI 
       MOV  A,M       ;GET THE INPUT BYTE 
       MOV  L,A       ;SAVE IT IN THE L-REGISTER
       CPI  377Q      ;POSSIBLE ERROR BYTE? 
       JNZ  GDC010    ;NO - CHECK FOR NORMAL MODE 
       LDA  ERRFLG    ;YES - GET ERROR FLAG 
       ANI  DCMERR    ;ERROR IN INPUT?
       JZ   GDC010    ;NO - PROCESS CHARACTER 
       POP  H         ;YES - RESTORE H,L
       CMP  A         ;RETURN ERROR WITH NO MESSAG
       STC              ;(C, Z) 
       RET            ;RETURN 
; 
;  PROCESS CHARACTER
; 
GDC010 EQU  $ 
       LDA  DCFLGS    ;GET DATACOM FLAGS
       MOV  H,A       ;SAVE FLAGS 
       ANI  BINMOD    ;BINARY MODE? 
       JNZ  GDC050    ;YES - DON'T CHECK FOR <ENQ>
       MOV  A,L 
       ANI  177Q      ;MASK OUT PARITY BIT
       MOV  L,A       ;SAVE CURRENT CHAR
       MOV  A,H       ;RECALL FLAGS 
       ANI  MCMOD     ;MAIN CHANNEL?
       JNZ  GDC015    ;NO, DO NOT CK ED CHAR
       LDA  ENDCHR    ;GET ED CHAR
       CMP  L 
       JNZ  GDC015    ;NO, CONTINUE 
       MOV  A,H       ;RECALL STRAPS
       ANI  TRNMOD    ;TRANSPARENT? 
       JNZ  GDC014    ;YES JMP
       LDA  KBJMP3    ;READ STRAPS
       ANI  CFSTRP    ;CF DETECT ENABLED ?
       JNZ  GDC012    ;NO, GO TO XMIT STATE 
       LXI  H,DCFLGS  ;GET DCFLGS ADDR
       DI 
       MOV  A,M       ;GET FLAGS
       ORI  SPECHO    ;SET SUPPRESS ECHO
       MOV  M,A       ;STORE NEW FLAGS
       EI 
       JMP  GDC002    ;GO EXIT ON WAIT DROP CF
GDC012:PUSH B         ;SAVE B,C 
       CALL DCM030    ;YES, GO TO TRANSMIT STATE
       POP  B 
       POP  H 
       ORI  1 
       RET
; 
GDC014 EQU  $ 
       PUSH B 
       CALL DCM030
       POP  B 
       POP  H 
       LDA  ENDCHR     ;GET ED CHAR 
       CMP  A 
       RET
; 
GDC015 EQU  $ 
       MOV  A,H       ;RECALL FLAGS 
       ANI  TRNMOD+SPECHO ;TRANSPARENT OR WAITING 
       JNZ  GDC050    ;YES, JMP 
       MOV  A,L       ;RECALL CHAR
       CPI  ENQ       ;IS IT AN <ENQ>?
       POP  H         ;RESTORE H,L
       JZ   GDC020    ;YES - RESPOND WITH <ACK> 
       CMP  A         ;NO - RETURN CHARACTER
       RET              ;(NC, Z)
 
; 
;  WAIT FOR LINE TURNAROUND BEFORE SENDING <ACK>
; 
GDC020 EQU  $ 
       CALL GDC004    ;CHECK FOR END OF DATA
       LDA  DCFLGS    ;GET THE DATACOM FLAGS
       ANI  DCCA      ;TRANSMIT MODE (CA = 1)?
       JNZ  GDC020    ;NO - WAIT FOR TURNAROUND 
GDC030 EQU  $         ;YES - SEND ACK 
       MVI  A,ACK 
       ORA  A         ;NC => NORMAL CHAR
       CALL PUTDC 
       JC   GDC030    ;ERROR - TRY AGAIN
       JNZ  GDC030    ;WAIT - TRY AGAIN 
       LDA  DCFLGS    ;SEE IF ENQ-ACK SHOULD CAUSE
       CMA              ;CHANGE TO BINARY MODE
       ANI  GOBIN 
       RNZ            ;NO - RET WITH NC,NZ => WAIT
       DI 
       LDA  DCFLGS    ;YES - TOGGLE GOBIN AND BINM
       XRI  GOBIN+BINMOD
       STA  DCFLGS
       EI 
       XRA  A         ;CLEAR FP MASK
       STA  FPMASK
       INR  A 
       RET
; 
;  BINARY OR TRANSPARENT - RETURN CHARACTER 
; 
GDC050 EQU  $ 
       MOV  A,L         ;(PUT CHARACTER IN A-REG) 
       POP  H 
       CMP  A         ;RETURN CHARACTER 
       RET              ;(NC, Z)
 
; 
; * * * * * * * * * * * * * * * * * * * * * * * * 
; 
;  GETBIN - GET A BINARY BYTE 
; 
;      ENTRY:  DON'T CARE 
; 
;      EXIT :  SAME AS GETDC, ABOVE 
; 
GETBIN EQU  $ 
       PUSH H 
       LXI  H,DCFLGS
       MOV  A,M       ;LOAD DC FLAGS
       ANI  BINMOD    ;ALREADY IN BINARY MODE?
       DI 
       MOV  A,M 
       JNZ  GDC001    ;YES - GET BYTE AND RETURN
       ORI  GOBIN     ;NO - SET FLAG TO GO TO BIN 
       MOV  M,A 
       EI 
       POP  H 
       CALL GETDC     ;EMPTY BUF/DO ENQ-ACK HANDSH
       ORI  1         ;NC,NZ => WAIT
       RET
 
; 
; * * * * * * * * * * * * * * * * * * * * * * * * 
; 
;  DCMON - NORMAL DATA COMM MONITOR ROUTINE 
; 
;      ENTRY:  DON'T CARE 
; 
;      EXIT :  ALL REGISTERS DESTROYED
; 
;  THIS ROUTINE MONITORS THE RS232-C CONTROL
;  LINES CLEAR TO SEND (CB,106), RECEIVE CARRIER
;  (CF,109), AND SECONDARY RECEIVE DATA (SB,122). 
; 
;  THE DATA SET READY LINE (CC, 107) IS MONITORED 
;  WHEN THE GP ASYNC DC CARD IS USED AND
;  IF THE CHEKCC IS ENABLE THE TRANSMIT LED IS
;  TURNED ON WHEN CC IS HIGH, OFF WHEN LOW, ELSE
;  IF THE CHEKCC IS DISABLED, THEN
; 
;  THE TRANSMIT LIGHT IS TURNED ON WHEN CB (106)
;  IS HIGH (DCCB=0), AND OFF, WHEN CB (106) IS
;  LOW (DCCB=1).
; 
;  IF CIRCUIT ASSURANCE IS ENABLED AND IN RECEIVE 
;  STATE, TRANSITION TO TRANSMIT, IS ENABLED ONLY 
;  AFTER DROP IN BOTH CB, AND SB HAS BEEN DETECTED
;  WITHIN 2.6 SECS, ELSE RETURN TO RECEIVE STATE. 
; 
;  IF CIRCUIT ASSURANCE IS DISABLED TRANSITION
;  WILL OCCUR AFTER A DROP IN CB. 
; 
;  IF CPU BREAK IS ENABLED AND IN TRANSMIT STATE, 
;  IF SB DROPS, THE CPU HAS ENABLED BREAK.IF BREAK
;  HAS OCCURED AND CF DETECT IS DISABLED, SEND ED 
;  CHAR AND SET CA LOW, ELSE SET CA LOW . 
; 
;  IF CARRIER DETECT CF IS ENABLE IN RECEIVE STATE
;  WITH A DROP IN CF DETECTED THEN GO TO TRANSMIT 
;  STATE. IF CARRIER DETECT IS DISABLED, AND MAIN 
;  CHANNEL, THEN TURN LINE AROUND AFTER ED CHAR.
; 
; 
DCMON  EQU  $ 
       LDA  DCCT      ;READ CONTROL WD
       MOV  D,A       ;SAVE CH,NP,CA
       LDA  DCFLGS    ;GET DATA COMM FLAGS
       ANI  FB9600    ;FAST BINARY? 
       MVI  A,B9600+DCNP  ;SET FASTBIN
       JNZ  DCM002    ;YES, 
       LDA  KBDCSW    ;READ DCSW
       ANI  BAUDPT    ;CLEAR H/F AND CA BITS
DCM002:ORA  D           ;KEYBOARD DATACOM SWITCHES
       STA  IODCCT    ;SET BAUD RATE AND PARITY 
       LDA  IODCST    ;GET CURRENT DATA COMM STATU
       MOV  C,A       ;SAVE IT IN C 
       LXI  H,DCSTAT
       MOV  B,M       ;GET PREVIOUS STATUS AND
       MOV  M,A         ;SAVE NEW STATUS
       LDA  KBJMP3    ;READ STRAPS
       MOV  E,A       ;SAVE IN E
       ANI  CHEKCC    ;MONITOR CC ? 
       JZ   DCM005    ;NO USE CB
       LDA  IODCS2    ;READ 2ND STATUS
       ANI  DCCC      ;IS CC HIGH ? 
       JMP  DCM010    ;GO TO SET LED
DCM005:MOV  A,C       ;RECALL STATUS
       ANI  DCCB      ;IS CB HIGH (DCCB = 0)? 
DCM010:CZ   ZSTXMT    ;YES - TURN ON TRANSMIT LED 
       CNZ  ZCLXMT    ;NO - TURN OFF TRANSMIT LED 
       MOV  A,D       ;IN 202 RECEIVE MODE (CA = 0
       RRC              ;DCCA = 1)? 
       MOV  A,E       ;RECALL STRAPS
       JNC  DCM100    ;NO - CHECK FOR DROP IN SB
 
; 
;  IN RECEIVE MODE (DCCA = 1 => CA = 0) - CHECK 
;    FOR DROP IN CF TO GO TO TRANSMIT MODE
;    IF CARRIER DETECT IS ENABLED 
; 
       ANI  CFSTRP     ;CARRIER DETECT ENABLED? 
       RNZ            ;NO , IGNORE CF 
       MOV  A,B       ;PUT CURRENT STATUS IN A
       XRA  C         ;EXTRACT CHANGED BITS 
       ANI  DCCF      ;DID RECEIVE CARRIER (CF) 
       ANA  C           ;DROP (DCCF -> 1)?
       RZ             ;NO - RETURN
DCM030 EQU  $ 
       LXI  H,DCFLGS  ;YES - PREPARE TO GO INTO 
       DI 
       MOV  A,M         ;TRANSMIT MODE
       ORI  SPECHO    ;SET FLAG TO IGNORE INPUT 
       MOV  M,A         ;FROM DATA COMM 
       EI 
       XRA  A         ;CLEAR TRANSMIT TURN AROUND 
       STA  XMTDLY      ;TIME LIMIT 
       MVI  A,1 
DCM040 EQU  $ 
       MVI  B,0       ;SET TO TURN ON CA
       LXI  H,DCM050  ;SET CLEAN-UP ROUTINE 
       JMP  DCTURN    ;DO TURN AROUND 
; 
;  CHECK FOR TRANSMIT TURN AROUND COMPLETION
; 
DCM050 EQU  $ 
       LDA  IODCST    ;GET CURRENT STATUS 
       STA  DCSTAT    ;UPDATE STATUS
       MOV  B,A 
       ANI  DCCB      ;IS CB ON? (=0) 
       JNZ  DCM055    ;NO, CONTINUE WAIT
       LDA  KBJMP2    ;MONITOR SB?
       ANI  SBSTRP
       JNZ  DCM060    ;NO, GO TO TRANSMIT STATE 
       MOV  A,B       ;YES, IS SB ON? (=0)
       ANI  DCSB
       JZ   DCM060    ;YES,GO TO TRANSMIT STATE 
DCM055 EQU  $ 
       LXI  H,XMTDLY  ;TURN AROUND TIME LIMIT 
       DCR  M           ;EXCEEDED?
       JZ   DCM110    ;YES - REVERT TO RECEIVE MOD
       RET            ;NO - RETURN (CONTINUE WAIT)
; 
;  TURN AROUND COMPLETED - SET FOR TRANSMIT MODE
; 
DCM060 EQU  $         ;SET TRANSMIT MODE CA 
       LXI  H,DCFLGS
       DI 
       MOV  A,M 
       ANI  377Q-DCCA 
       MOV  M,A 
       LXI  H,DCCT    ;SET CONTROL WD ADDR
       MOV  A,M       ;READ WD
       ANI  DCCH+DCNP  ;SET CA LOW
       MOV  M,A       ;SET NEW WD 
       LXI  H,DCMON   ;SET MONITOR VECTOR TO
       SHLD DCMVEC      ;REGULAR MONITOR ROUTINE
       LXI  H,CMFLGS
       MOV  A,M 
       ORI  BLKTRG    ;SET BLOCK TRANSFER TRIGGER 
       MOV  M,A 
       EI 
       LDA  KBJMP3    ;MAIN CHANNEL PROTOCOL? 
       MOV  B,A 
       ANI  MNCHAN
       RZ             ;NO, RETURN 
       MOV  A,B       ;YES, SEND START OF DATA? 
       ANI  STXSTP
       RNZ            ;NO, RETURN 
DCM070 EQU  $ 
       LDA  DCFLGS    ;READ FLAGS 
       ANI  TRNMOD    ;TRANSPARENT? 
       RNZ             ;YES - RETURN
DCM075 EQU  $ 
       MVI  A,STX     ;SET STX AS SD
       CALL PUTDC 
       JC   DCM075
       JNZ  DCM075
       RET            ;RETURN 
 
; 
;  IN TRANSMIT MODE (DCCA = 0 => CA = 1) - CHECK
;    FOR DROP IN SB TO GO TO RECEIVE MODE 
; 
DCM100 EQU  $ 
       ANI  CBKSTP
       RNZ
       MOV  A,B 
       XRA  C         ;EXTRACT CHANGED BITS 
       ANI  DCSB      ;DID SECONDARY RECEIVED DATA
       ANA  C           ;(SB) DROP (DCSB -> 1)? 
       RZ             ;NO - RETURN
       MOV  A,E 
       ANI  MNCHAN    ;MAIN CHANNEL?
       JZ   DCM110    ;NO,
DCM105 EQU  $ 
       LDA  ENDCHR    ;OUTPUT ED CHAR 
       CALL PUTDC 
       JC   DCM105
       JNZ  DCM105
       RET
; 
DCM110 EQU  $         ;YES - GO TO RECEIVE MODE 
       LXI  H,CMFLGS
       DI 
       MOV  A,M       ;CLEAR BLOCK TRANSFER TRIGGE
       ANI  377Q-BLKTRG 
       MOV  M,A 
       MVI  B,DCCA    ;SET TO TURN OFF CA 
       LXI  H,DCFLGS  ;SET CA IN "DCFLGS" TO
       MOV  A,M         ;INHIBIT TRANSMISSION 
       ORA  B           ;OF DATA
       MOV  M,A 
       LXI  H,DCCT    ;SET CONTROL WD ADDR
       MOV  A,M 
       ORI  DCCA      ;SET CA 
       MOV  M,A 
       EI 
       MVI  A,1       ;SET SETTLING TIME (10 MSEC)
       LXI  H,DCM150  ;SET CLEAN-UP ROUTINE 
       JMP  DCTURN    ;DO TURN AROUND 
; 
;  TURN AROUND DONE - SET FOR RECEIVE MODE
; 
DCM150 EQU  $ 
       LXI  H,DCMON   ;SET MONITOR VECTOR TO
       SHLD DCMVEC      ;REGULAR MONITOR ROUTINE
       DI 
       LHLD DCBFBG    ;SET DATA COMM BUFFER 
       SHLD DCSPTR      ;POINTERS 
       SHLD DCBPTR
       EI 
       LDA  IODCST    ;READ STATUS
       STA  DCSTAT    ;UPDATE STATUS
       LDA  KBJMP3    ;MAIN CHANNEL PROTOCOL? 
       MOV  B,A 
       ANI  MNCHAN
       MOV  A,B 
       JZ   DCM160    ;NO, RESET ECHO SUPPRESS
       ANI  STXSTP    ;YES,WAIT FOR STRT OF DATA? 
       RZ             ;YES, RETURN NOW
DCM160 EQU  $ 
       LXI  H,DCFLGS  ;SET DATA COMM FLAGS TO 
       DI 
       MOV  A,M         ;ACCEPT DATA COMM INPUT 
       ANI  377Q-SPECHO 
       MOV  M,A 
       EI 
       RET            ;RETURN 
 
; 
; * * * * * * * * * * * * * * * * * * * * * * * * 
; 
;  DCTURN - TURN LINE AROUND FOR 202
; 
;      ENTRY:  A = SIGNAL SETTLING TIME 
;              B = SETTING FOR CA 
;              H,L = TURN AROUND EXIT ROUTINE 
; 
;      EXIT :  A,B,H,L DESTROYED
; 
DCTURN EQU  $ 
       STA  DCDLAY    ;SET SIGNAL SETTLING DELAY
       SHLD DCTEX     ;SET DATA COMM EXIT ROUTINE 
       LXI  H,DCDCNT  ;SET MONITOR JUMP FOR DELAY 
       SHLD DCMVEC      ;CONTINUATOR
       LDA  DCCT      ;READ CONTROL WD
       ANI  377Q-DCCA  ;SET CLEAR 
       ORA  B         ;MASK WITH DCCA 
       MOV  B,A       ;SAVE IN B
DCT010 EQU  $ 
       LDA  KBDCSW    ;ADD DESIRED CA SETTING WITH
       ANI  BAUDPT    ;CLEAR H/F AND CA BITS
       ORA  B           ;KEYBOARD DATACOM SWITCHES
       STA  IODCCT    ;SET DATA COMM INTERFACE
       RET            ;RETURN 
; 
;  TURN AROUND CONTINUATOR - CHECK FOR TIME OUT 
; 
DCDCNT EQU  $ 
       LXI  H,DCDLAY
       DCR  M         ;SETTLING TIME COMPLETED? 
       RNZ            ;NO - RETURN
       LHLD DCTEX     ;YES - GET CLEAN UP ROUTINE 
       SHLD DCMVEC      ;ADDRESS AND GO DO IT 
       PCHL 
 
; 
; * * * * * * * * * * * * * * * * * * * * * * * * 
; 
;  DCCTL - PERFORM CONTROL FUNCTIONS
; 
;      ENTRY:  A = CONTROL PARAMETER
;              B,C = CONTROL VARIABLES (AS NEEDED)
; 
;      EXIT :  A DESTROYED
;              NC - NO DATACOM ERRORS DETECTED
;                Z - CONTROL PERFORMED
;                NZ - INVALID CONTROL REQUEST 
;              C - DATACOM ERROR DETECTED 
;                Z - NO ERROR MESSAGE 
;                NZ - DISPLAY ERROR MESSAGE 
;                  B,C = POINTER TO ERROR MESSAGE 
; 
DCCTL  EQU  $ 
       CPI  PROMPT    ;IS CONTROL CALL PROMPT?
       JZ   SNDDC2    ;YES, JMP 
       RNC            ;IF GREATER RET INVALID CNTL
       PUSH H         ;SAVE THE WORKING REGISTERS 
       PUSH D 
       ADD  A         ;DOUBLE THE PARAMETER VALUE 
       MOV  E,A       ;COMPUTE CONTROL VECTOR 
       MVI  D,0         ;LOCATION 
       LXI  H,DCCTAB
       DAD  D 
       MOV  E,M       ;FETCH THE CONTROL VECTOR 
       INX  H 
       MOV  D,M 
       XCHG 
       POP  D         ;RECALL D AND E 
       PCHL           ;GO TO CONTROL ROUTINE
; 
;  CONTROL VECTORS
; 
DCCTAB EQU $
       DW   CLBLTR    ;0 - CLEAR BLOCK XFR TRIGGER
       DW   STBLTR    ;1 - SET BLOCK XFR TRIGGER
       DW   RSTDCM    ;2 - RESET DATACOM
       DW   STRMTE    ;3 - SET REMOTE MODE
       DW   STLOCL    ;4 - SET LOCAL MODE 
       DW   BREAK     ;5 - OUTPUT BREAK SIGNAL
       DW   DSCNCT    ;6 - MODEM DISCONNECT 
       DW   SNDTRM    ;7 - SEND ED IF MAIN CHAN 
       DW   ENTMON    ;8 - ENTER MONITOR MODE 
       DW   RETNRM    ;9 - RETURN TO NORMAL OPER
       DW   FSTBIN   ;10 - FAST BINARY 9600 BAUD
       DW   GDC002   ;11 - NO OP
       DW   GDC002   ;12 - NO OP
;      DFAD SNDDC2   13 - SEND DC2
 
; 
;  CLBLTR - CLEAR BLOCK TRANSFER TRIGGER
; 
CLBKTX EQU  $ 
       PUSH H         ;ENTRY FOR SEND DC2 ROUTINE 
CLBLTR EQU  $ 
       MVI  A,377Q-BLKTRG  ;SET FLAG TO BE CLEARED
       LXI  H,CMFLGS  ;SET H,L TO COMMON FLAGS
       ANA  M         ;MASK OUT THE FLAG
       MOV  M,A       ;STORE UPDATED VALUE
DCCTX1 EQU  $ 
       POP  H         ;RESTORE H AND L
       CMP  A         ;SET NC AND Z 
       RET            ;RETURN 
; 
; 
; 
;  STBLTR - SET BLOCK TRANSFER TRIGGER
; 
STBLTR EQU  $ 
       LDA  DCFLGS    ;GET THE DATACOM FLAGS
       ANI  DCCA      ;IN 202 RECEIVE MODE? 
       JNZ  DCCTX1    ;YES - RETURN WO/SETTING FLA
       MVI  A,BLKTRG  ;NO - SET THE BLOCK TRANSFER
       LXI  H,CMFLGS    ;TRIGGER
       ORA  M 
       MOV  M,A 
       JMP  DCCTX1    ;RETURN 
; 
;  RSTDCM - RESET DATACOM 
; 
RSTDCM EQU  $ 
       CALL RSTDCB    ;RESET DATACOM FLAGS AND PTR
       JMP  DCCTX1    ;RETURN 
; 
;  STRMTE - SET REMOTE MODE 
; 
STRMTE EQU  $ 
       DI 
       LDA  KBJMP3    ;READ DC JUMPERS
       MOV  H,A       ;SAVE IN H
       CALL RSTSRM    ;DO PARTIAL RESET 
       EI 
       JMP  DCCTX1    ;RETURN 
; 
;  STLOCL - SET LOCAL MODE
; 
STLOCL EQU  DCCTX1    ;NO FUNCTION
 
; 
;  BREAK - OUTPUT BREAK SIGNAL
; 
BREAK  EQU  $ 
       CALL CHKDCM    ;MAKE SURE DATA COMM IS IDLE
       LDA  DCCT      ;READ CONTROL WD
       ORI  DCSA      ;ADD IN BREAK BIT 
       MOV  H,A       ;SAVE CONTROL BYTE
       LDA  KBDCSW    ;READ SWITCHES
       ANI  BAUDPT    ;CLEAR H/F AND CA BITS
BRK005 EQU  $ 
       ORA  H 
       STA  IODCCT    ;SET INTERFACE TO BREAK 
       LXI  H,BRK050  ;SET BREAK EXIT AND BREAK 
       MVI  A,21        ;TIME (210 MSEC)
BRK010 EQU  $ 
       STA  DCDLAY    ;SET DELAY INTERVAL 
       SHLD DCTEX     ;SET EXIT ROUTINE 
       LXI  H,DCDCNT  ;SET MONITOR VECTOR TO
       SHLD DCMVEC      ;DELAY CONTINUATOR
       CALL CHKDCM    ;WAIT UNTIL DELAY IS COMPLET
       EI             ;ENABLE INTERRUPT 
       JMP  DCCTX1    ;RETURN SUCCESSFUL
; 
; 
;  DISCONNECT EXIT ROUTINE
; 
DSC100 EQU  $ 
       LDA  DCCTL2    ;SET CD BACK ON 
;  BREAK EXIT ROUTINE 
; 
BRK050 EQU  $ 
       LDA  DCCT      ;READ CONTROL WD
       MOV  H,A       ;SAVE CONTROL BYTE
       LDA  KBDCSW    ;READ SWITCHES
       ANI  BAUDPT    ;CLEAR H/F AND CA BITS
BRK100 EQU  $ 
       ORA  H 
       STA  IODCCT
       LXI  H,DCMON   ;RESTORE MONITOR VECTOR 
       SHLD DCMVEC
       RET            ;RETURN 
; 
;  DSCNCT - MODEM DISCONNECT
; 
DSCNCT EQU  $ 
       CALL CHKDCM    ;MAKE SURE DATA COMM IS IDLE
       LDA  DCCTL2+CDOFF  ;TURN OFF DATA TERMINAL 
       MVI  A,101       ;READY (CD) FOR ONE SECOND
       LXI  H,DSC100  ;SET EXIT ROUTINE ADDRESS 
       JMP  BRK010    ;SET MONITOR ROUTINE JUMP 
 
; 
;  TRMBIN - TERMINATE BINARY OUTPUT 
; 
TRMBIN EQU  $ 
       PUSH H 
       LXI  H,DCFLGS    ;CLEAR FAST BINARY
       DI 
       MOV  A,M 
       ANI  377Q-FB9600 
       MOV  M,A 
       EI 
       ANI  FORPAR    ;SET FP MASK
       STA  FPMASK
TRM005:LDA  IODCPC    ;GET DATA COMM PROGRAM STRAP
       ANI  GPASYC    ;IS IT THE GP ASYNC BOARD?
       JZ   TRM015    ;NO 
TRM010 EQU  $         ;YES - DROP REQUEST TO SEND 
       LDA  IODCS2    ;GET AUXILARY STATUS
       ANI  DCTBE     ;TRANSMIT BUFFER EMPTY? 
       JZ   TRM010    ;NO - CONTINUE MAITING
       CALL CHKDCM    ;MAKE SURE DATA COMM IS IDLE
       MVI  A,1       ;DELAY FOR 10 MSEC
TRM012 EQU  $ 
       LXI  H,TRM020  ;SET EXIT 
       JMP  BRK010    ;SET MONITOR JUMP ADDRESS 
; 
TRM015 EQU  $ 
       LDA  IODCST     ;READ STATUS 
       ANI  DCTBE      ;IS XMIT BUFFER EMPTY? 
       JZ   TRM015      ;NO 
       CALL  CHKDCM    ;CHECK DATA COMM IDLE
       MVI  A,10       ;SET DELAY 100 MSEC
       JMP  TRM012
; 
;  CONTINUATION FOR BINARY TERMINATE
; 
TRM020 EQU  $ 
       LXI  H,DCCT    ;SET DCCT ADDR
       MOV  A,M       ;GET CONTROL WD 
       ANI  DCCH+DCCA ;CLEAR NO PARITY
       MOV  M,A       ;SET NORMAL 
       ORI  DCCA      ;SET REQ TO SEND OFF
       MOV  H,A 
       LDA  KBDCSW    ;TURN OFF REQUEST TO SEND 
       ANI  BAUDPT    ;CLEAR H/F AND CA BITS
TRM030 EQU  $ 
       ORA  H 
       STA  IODCCT
       MVI  A,1       ;SET FOR 10 MSEC INTERVAL 
       LXI  H,BRK050  ;EXIT VIA "BRK050"
       STA  DCDLAY
       SHLD DCTEX 
       LXI  H,DCDCNT  ;SET TO DELAY ROUTINE 
       SHLD DCMVEC
       RET            ;RETURN TO TIMER INTERRUPT
 
; 
;  ENTMON - ENTER MONITOR MODE
; 
ENTMON EQU  $ 
       MVI  A,TRNMOD  ;SET TRANSPARENT MODE 
       LXI  H,DCFLGS    ;FLAG 
       DI 
       ORA  M 
       MOV  M,A       ;UPDATE FLAG SETTING
       EI 
       XRA  A 
       STA  FPMASK
       JMP  DCCTX1    ;RETURN 
; 
;  RETNRM - RETURN TO NORMAL MODE 
; 
RETNRM EQU  $ 
       MVI  A,377Q-TRNMOD   ;CLEAR TRANSPARENT MOD
       LXI  H,DCFLGS
       DI 
       ANA  M 
       MOV  M,A       ;UPDATE FLAG SETTINGS 
       EI 
       ANI  FORPAR
       STA  FPMASK    ;SET FP MASK
       JMP  DCCTX1    ;RETURN 
; 
;  FSTBIN - FAST BINARY ROUTINE GOTO 9600 BAUD
; 
FSTBIN EQU  $ 
       LDA  KBJMPR    ;READ JUMPER A-H
       ANI  FSTSND    ;IS FAST SEND ENABLED?
       JZ   FST010    ;NO RETURN
       LXI  H,DCFLGS  ;GET FLAGS
       DI 
       MOV  A,M 
       ORI  FB9600    ;SET FLAG FOR FAST BIN
       MOV  M,A       ;STORE NEW FLAG 
       EI 
FST010:CALL STRTBN    ;SET BINARY OUTPUT MODE 
       JMP  DCCTX1    ;RETURN 
 
; 
; * * * * * * * * * * * * * * * * * * * * * * * * 
; 
;  CHKDCM - WAIT FOR MONITOR TO CLEAR 
; 
;      ENTRY:  DON'T CARE 
; 
;      EXIT :  DCMVEC = DCMON 
;              H-L DESTROYED
;              INTERRUPTS DISABLED
CHKDCM EQU  $ 
       LXI  H,DCMON   ;GET NORMAL MONITOR ADDRESS 
       DI             ;DISABLE INTERRUPTS 
       LDA  DCMVEC    ;GET CURRENT MONITOR VECTOR 
       CMP  L         ;IS IT THE NORMAL ROUTINE?
       JNZ  CKD020    ;NO - TRY AGAIN 
       LDA  DCMVEC+1
       CMP  H         ;DOES MSB MATCH?
       RZ             ;YES - RETURN 
CKD020 EQU  $         ;NO - TRY AGAIN 
       EI             ;RE-ENABLE INTERRUPTS 
       JMP  CHKDCM    ;CHECK AGAIN
 
; 
;***********************************************
; 
;  SNDDC2 - SEND DC2
; 
;     ENTRY: DON'T CARE 
; 
;     EXIT : A DESTROYED
; 
; 
SNDDC2 EQU  $ 
       CALL CLBKTX    ;GO TO CLEAR BLOCK TRIGGER
SND010 EQU  $ 
       MVI  A,DC2     ;SET DC2 AS CHAR
       CALL PUTDC     ;OUTPUT DC2 
       RC             ;RETURN ON DC ERROR 
       JNZ  SND010
       LDA  KBJMPR    ;READ KB JUMPERS
       CMA            ;REVERSE SENSE OF BITS
       ANI  PAGSTR    ;PAGE STRAP IN ?
       RZ             ;NO - RETURN
SND020 EQU  $ 
       MVI  A,CR      ;SET CR AS CHAR 
       CALL PUTDC     ;OUTPUT CR
       RC             ;RETURN ON DC ERROR 
       JNZ  SND020
       LDA  MDFLG2    ;READ MODE
       ANI  AUTOLF    ;AUTO LF KEY DOWN?
       RZ             ;NO RETURN
SND030 EQU  $ 
       MVI  A,LF      ;SET LF AS CHAR 
       CALL PUTDC     ;OUTPUT LF
       RC             ;RETURN ON DC ERROR 
       JNZ  SND030
       RET            ;EXIT 
 
; 
;****************************************** 
; 
;  SNDTRM - SEND ED CHAR IF MAIN CHANNEL
; 
; 
SNDTRM EQU  $ 
       LDA  DCFLGS    ;READ FLAGS 
       ANI  MCMOD+DCCA ;MAIN CHANNEL? 
       JNZ  DCCTX1    ;NO RETURN
       JMP  PDC060    ;SEND ED CHAR 
 
; 
; * * * * * * * * * * * * * * * * * * * * * * * * 
; 
;  DCTST - DATACOM SELF-TEST
; 
;      ENTRY:  DON'T CARE 
; 
;      EXIT :  NC - SELF-TEST SUCCESSFUL
;              C - SELF-TEST FAILED 
;              H,L = SELF-TEST MESSAGE
;              OTHER REGS. DESTROYED
; 
DCTST  EQU  $ 
;*******************
; DISALLOW DATACOM *
; INTERRUPTS       *
;*******************
       LDA  KBJMP3
       ANI  NODCST
       JNZ  SFT600
       LXI  H,PRCCTL  ;PROCESSOR CONTROL FLAG 
       DI 
       MOV  A,M 
       ORI  DCIOFF    ;DON'T LET TIMER ROUTINE
       MOV  M,A         ;REENABLE DATACOM INT.
       OUT  PROCSR    ;DISABLE DATACOM INT. 
       EI 
; 
       LXI  H,TMOUT   ;GIVE CONTROL TO TIMEOUT
       SHLD DCMVEC    ;ROUTINE ON TIMER INTS. 
;********** 
; DATACOM * 
; ALIVE?  * 
;********** 
       SUB  A         ;RAISE REQUEST TO SEND
       STA  IODCCT
       MVI  B,DCCB    ;CHECK FOR CLEAR TO SEND
       MOV  C,B 
       CALL STATCH    ;CHECK DATA COM STATUS
       LXI  H,STCACB  ;ERROR MESSAGE POINTER
       JZ   SFT400    ;INDICATE FAILURE 
 
;***************
; CHECK DATA   *
; SEND RECEIVE *
; LOOP         *
;***************
       MVI  A,DCNP    ;SET INITIAL PARITY - NONE
SFT130 EQU  $ 
       STA  TPARIT
       MVI  B,B9600   ;9600 BAUD
       ADD  B         ;COMBINE BAUD RATE AND PARIT
       STA  IODCCT   ;SET THEM
       LDA  IODCDI    ;CLEAR DATA IN REGISTER 
       MVI  D,0       ;INITIALIZE TO FIRST CHAR 
; SEND CHARACTER
SFT170 EQU  $ 
       MVI  B,DCTBE   ;WAIT TILL XMIT BUFER MT
       MVI  C,0 
       CALL STATCH
       LXI  H,STDATA  ;IN CASE OF FAIL
       JZ   SFT400    ;FAILURE
       MOV  A,D 
       STA  IODCDO    ;SEND DATA
       MVI  B,DCDP    ;WAIT UNTIL DATA PRESENT
       MVI  C,0 
       CALL STATCH
       JZ   SFT400    ;FAILED-NO CHAR REC'D 
       LDA  IODCDI    ;GET CHARACTER
       MOV  B,A       ;SAVE 
; CHECK PARITY
SFT200 EQU  $ 
       LDA  IODCST    ;DATACOM STATUS 
       MOV  C,A       ;SAVE 
       ANI  DCPE      ;PARITY ERROR BIT SET?
       LXI  H,STPARE  ;PARITY ERROR MSG PTR 
       JNZ  SFT400    ;YES, ERROR 
; OVERRUN ERROR?
       MOV  A,C       ;STATUS 
       ANI  DCOE      ;CHECK BIT
       LXI  H,STOVRE  ;MSG POINTER
       JNZ  SFT400    ;ERROR
; CHECK CHARACTER 
       MOV  A,B       ;DATACOM CHARACTER
       CMP  D         ;SAME AS SENT?
       LXI  H,STDATA  ;ERROR POINTER
       JNZ  SFT400
; DO NEXT CHARACTER 
       INR  D         ;BUMP TO NEXT CHARACTER 
       JZ   SFT260    ;WAS 8 BIT TEST, DONE 
       JP   SFT170    ;.LE. 177B
       LDA  TPARIT    ;NO PARITY? 
       CPI  DCNP
       JZ   SFT170    ;YES, USE 8 BITS
; 
;  DO NEXT PARITY SETTING 
; 
SFT260 EQU  $ 
       LDA  TPARIT
       CPI  DCNP
       JZ   SFT280    ;NO PARITY, USE ODD NEXT
       CPI  DCOP      ;ODD PARITY 
       JNZ  SFT300    ;NO, MUST BE DONE 
       MVI  A,DCEP    ;DO EVEN PARITY 
       JMP  SFT130
SFT280 EQU  $ 
       MVI  A,DCOP      ;ODD PARITY 
       JMP  SFT130
 
;*************
; TEST OTHER *
; BAUD RATES *
;*************
SFT300 EQU  $ 
       MVI  D,7       ;BAUD COUNTER 
SFT320 EQU  $ 
       DCR  D         ;DO NEXT BAUD RATE
       JZ   SFT340    ;ALL BAUD RATES TESTED
       MOV  A,D       ;FORMAT CONTROL WORD
       RLC            ;SHIFT TO BITS 1-3
       MVI  B,DCNP    ;NO PARITY
       ADD  B 
       STA  IODCCT    ;SET NO PARITY AND BAUD 
       SUB  A 
       STA  IODCDO    ;SEND NULL
       MVI  B,DCDP
       MVI  C,0 
       CALL STATCH    ;WAIT FOR DATA
       LXI  H,STDATA  ;ERROR MSG
       JZ   SFT400    ;NO DATA RECEIVED 
       LDA  IODCDI    ;GET DATA 
       ORA  A         ;IS IT ZERO?
       JNZ  SFT400    ;NO, ERROR
       MVI  A,377Q    ;SEND ALL ONES
       STA  IODCDO
       CALL STATCH
       JZ   SFT400    ;ERROR
       LDA  IODCDI    ;CHECK DATA 
       INR  A 
       JNZ  SFT400    ;NOT 377, ERROR 
       JMP  SFT320    ;DO NEXT BAUD RATE
 
;******** 
; TEST  * 
; LINES * 
;******** 
SFT340 EQU  $ 
       LXI  D,LINTBL  ;TABLE OF PATTERNS
SFT360 EQU  $ 
       LDAX D         ;GET DATACOM CONTROL WORD 
       INR  A         ;END? 
       JZ   SFT380    ;DONE, ALL TESTS PASSED 
       DCR  A         ;RESTORE A
;  SET DATACOM CONTROL
       STA  IODCCT
       MVI  B,DCCB    ;CHECK CB 
       INX  D         ;BUMP TO NEXT TABLE ENTRY 
       LDAX D 
       MOV  C,A 
       CALL STATCH
       LXI  H,STCB
       JZ   SFT400    ;CB ERROR 
       MVI  B,DCCF    ;CHECK CF 
       INX  D 
       LDAX D 
       MOV  C,A 
       CALL STATCH
       LXI  H,STCACF
       JZ   SFT400    ;ERROR
       MVI  B,DCSB    ;CHECK SB 
       INX  D 
       LDAX D 
       MOV  C,A 
       CALL STATCH
       LXI  H,STBKSB
       JZ   SFT400    ;ERROR
; 
       INX  D         ;BUMP TO NEXT TEST SET
       JMP  SFT360
 
;***************
; REPORT FINAL *
; STATUS BACK  *
;***************
; 
; GOOD STATUS 
; 
SFT380 EQU  $ 
       LXI  H,STGOOD  ;GOOD STATUS
       ANA  A         ;CLEAR CARRY
       JMP  SFT520    ;FINISH 
; 
; ERRORS
; 
SFT400 EQU  $ 
       SHLD MSGPT4    ;SET FAIL MSG 
       LXI  H,STFAIL  ;FAIL LITERAL 
       STC            ;SET CARRY TO INDICATE ERROR
;*********
; RETURN *
;*********
SFT520 EQU  $ 
       PUSH PSW       ;SAVE FLAGS 
       SHLD MSGPT3    ;SET MESSAGE TYPE 
       MVI  B,DCDP    ;CLEAR CHARACTER INPUT BUFFE
       MVI  C,0 
       CALL STATCH
       LDA  IODCDI
; 
       LXI  H,DCMON   ;RESET DC MONITOR ADDRESS 
       SHLD DCMVEC
       LXI  H,PRCCTL  ;PRECESSOR CONTROL FLAG 
       DI 
       MOV  A,M 
       ANI  377Q-DCIOFF  ;ENABLE DATACOM INTS.
       MOV  M,A 
       EI 
       POP  PSW 
SFT530:LXI  H,STSFTS
       SHLD MSGPT2
       LXI  H,DCTYPE  ;SET DATACOM TYPE MESSAGE 
       RET
SFT600:LXI  H,STDISA
       SHLD MSGPT3
       JMP  SFT530
 
;***************************
; TIMING ROUTINE           *
; THIS IS CALLED ON        *
; EVERY TIMER INTERRUPT    *
; AND DECREMENTS A COUNTER *
;                          *
;      ENTRY: DON'T CARE   *
;      EXIT:  H,L,FLAGS    *
;        CHANGED           *
;***************************
TMOUT  EQU  $ 
       LXI  H,TMOCNT  ;COUNTER
       DCR  M 
       RET
 
;*****************************
; CHECK DATACOM STATUS       *
;   AND WATCH FOR TIMEOUT    *
;                            *
; ENTRY:  B= BIT IN STATUS   *
;      TO BE EXAMINED        *
;                            *
;      C= B IF WE WANT BIT   *
;      TO TURN ZERO          *
;      C= 0 IF WE WANT BIT   *
;      TO EQUAL ONE          *
;      --SO EXCLUSIVE OR OF  *
;        STATUS AND C REG IS *
;        NON ZERO WHEN BIT   *
;        BECOMES THE VALUE   *
;        WE ARE LOOKING FOR  *
;                            *
; EXIT:  A= 0 IF BIT DID NOT *
;      TURN BY 400 MS        *
;        A .NE. 0 OTHERWISE  *
;      OTHER REGS. SAVED     *
;*****************************
STATCH EQU  $ 
       MVI  A,20
       STA  TMOCNT    ;INITIALIZE COUNTER 
; EXAMINE STATUS
STW100 EQU  $ 
       LDA  IODCST
       ANA  B         ;GET BIT DESIRED
       XRA  C         ;BIT IN RIGHT STATE?
       RNZ
; TIME OUT YET? 
       LDA  TMOCNT    ;TIME OUT COUNTER 
       ORA  A         ;ZERO?
       JNZ  STW100    ;NO 
       RET            ;YES, NEVER FOUND RIGHT STAT
 
;************ 
; SELF TEST * 
; LITERALS  * 
;************ 
DCTYPE EQU  $ 
       DB   'BASIC DATA COMM' 
       DB   EOL,0 
STSFTS EQU  $ 
       DB   'SELF TEST ',0
STGOOD EQU  $ 
       DB   'OK',EOP
STDISA EQU  $ 
       DB   'ERROR 0 (DISABLED)',EOP
STFAIL EQU  $ 
       DB   'ERROR ',0
STDATA EQU  $ 
       DB   '3 (LOST CHAR)',EOP 
STPARE EQU  $ 
       DB   '2 (PARITY)',EOP
STOVRE EQU  $ 
       DB   '3 (OVERRUN)',EOP 
STCACB EQU  $ 
       DB   '1 (NO CB)',EOP 
STCB   EQU  $ 
       DB   '4 (CB)',EOP
STCACF EQU  $ 
       DB   '4 (CF)',EOP
STBKSB EQU  $ 
       DB   '5 (SB)',EOP
 
;****************************** 
; DATACOM LINE TEST PATTERNS  * 
;                             * 
;  4 BYTES/ENTRY-TEST         * 
;  1ST = DATACOM CONTROL BYTE * 
;  2ND = CB WORD              * 
;  3RD = CF WORD              * 
;  4TH = SB WORD              * 
; THESE LAST 3 BYTES GO TO    * 
; C REG WHEN STATCH CALLED    * 
;****************************** 
LINTBL EQU  $ 
       DB   0         ;NOT CA = 0, BRK = 0
       DB   DCCB      ;NOT CB = 0 
       DB   DCCF      ;NOT CF = 0 
       DB   0         ;NOT SB = 1 
; 
       DB   1         ;NOT CA = 1, BRK = 0
       DB   0         ;NOT CB = 1 
       DB   0         ;NOT CF = 1 
       DB   DCSB      ;NOT SB = 0 
; 
       DB   101Q      ;CA = 1, BRK = 1
       DB   0         ;NOT CB = 1 
       DB   0         ;NOT CF = 1 
       DB   0         ;NOT SB = 1 
; 
       DB   377Q      ;END OF TABLE 
 
       END
