home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / MODEMS / MODEM7 / M7PP.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  20KB  |  727 lines

  1. ; M7PP.ASM -- Pied  Piper Overlay file for MEX/MDM7xx.  84/05/22
  2.  
  3. ; This overlay allows for either use of the DUAL Serial Card or the
  4. ; Serial/Modem Card. Port A's are interrupt driven while the Port B
  5. ; on the Dual card and the modem of the modem/serial card are not.
  6. ;
  7. ; The interrupts and Buffering allow the RS-232 ports to communicate
  8. ; error free up to 9600 baud (the 8251 only goes to 9600).
  9.  
  10. mainver equ    2        ; version 2 supports MEX overlay
  11. vers    equ    1
  12. year      equ    84
  13. month     equ    06
  14. day       equ    15
  15.  
  16. TRUE    EQU    0FFh
  17. FALSE   EQU    00
  18.  
  19. MEXOVL    EQU    false        ; <---- TRUE IF USED WITH MEX
  20.                 ;     FALSE IF USED WITH MDM7?0
  21.  
  22. ;    TO USE: First edit this file filling in answers for your own
  23. ;        equipment.  Then assemble with ASM.COM or equivalent
  24. ;        assembler.  Then use DDT to overlay the the results
  25. ;        of this program to the original .COM file:
  26. ;
  27. ;        A>DDT MDM7xx.COM
  28. ;        DDT VERS 2.2
  29. ;        NEXT  PC
  30. ;        4A00 0100
  31. ;        -IM7PP.HEX        (note the "I" command)
  32. ;        -R            ("R" loads in the .HEX file)
  33. ;        NEXT  PC
  34. ;        4A00 0000
  35. ;        -G0            (return to CP/M)
  36. ;        A>SAVE 73 MDM7xx.COM    (now have a modified .COM file)
  37.  
  38. ;       With MEX:
  39. ;
  40. ;        MLOAD MEX.COM=MEX??.COM,MXO-PP21
  41.  
  42. ; = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -
  43.  
  44. ; History as a MEX overlay
  45.  
  46. ; 15/06/84 - Finally got interrupt/buffering working error free at 9600, RCL
  47. ; 06/06/84 - VER 2.0 - Converted MDM overlay to be MEX/MDM compatible, RCL
  48.  
  49. ; History as a MDM Overlay
  50.  
  51. ; 30/05/84 - Added queue buffering for interrupt routine, Robert Lansdale
  52. ; 22/05/84 - Added interrupt routines to USART A          Robert Lansdale
  53. ; 09/05/84 - Converted M7GP-1.ASM to M7PP-1.ASM           Robert Lansdale
  54. ; 11/11/83 - Renamed to M7GP-1.ASM, no changes           Irv Hoff
  55. ; 07/27/83 - Renamed to work with MDM712           Irv Hoff
  56. ; 07/01/83 - Revised to work with MDM711           Irv Hoff
  57. ; 07/01/83 - Revised to work with MDM710           Irv Hoff
  58. ; 05/27/83 - Updated to work with MDM709           Irv Hoff
  59. ; 05/15/83 - Revised to work with MDM708           Irv Hoff
  60. ; 04/11/83 - Updated to work with MDM707           Irv Hoff
  61. ; 04/04/83 - First version of this file               Irv Hoff
  62. ;
  63. ; = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -
  64.  
  65.     IF     MEXOVL
  66.  
  67. ; MEX service processor stuff
  68.  
  69. MEX    EQU    0D00H        ;address of the service processor
  70. INMDM    EQU    255        ;get char from port to A, CY=no more in 100 ms
  71. TIMER    EQU    254        ;delay 100ms * reg B
  72. TMDINP    EQU    253        ;B=# secs to wait for char, cy=no char
  73. CHEKCC    EQU    252        ;check for ^C from KBD, Z=present
  74. SNDRDY    EQU    251        ;test for modem-send ready
  75. RCVRDY    EQU    250        ;test for modem-receive ready
  76. SNDCHR    EQU    249        ;send a character to the modem (after sndrdy)
  77. RCVCHR    EQU    248        ;recv a char from modem (after rcvrdy)
  78. LOOKUP    EQU    247        ;table search: see CMDTBL comments for info
  79. PARSFN    EQU    246        ;parse filename from input stream
  80. BDPARS    EQU    245        ;parse baud-rate from input stream
  81. SBLANK    EQU    244        ;scan input stream to next non-blank
  82. EVALA    EQU    243        ;evaluate numeric from input stream
  83. LKAHED    EQU    242        ;get nxt char w/o removing from input
  84. GNC    EQU    241        ;get char from input, cy=1 if none
  85. ILP    EQU    240        ;inline print
  86. DECOUT    EQU    239        ;decimal output
  87. PRBAUD    EQU    238        ;print baud rate
  88.  
  89. PRINT    EQU    9        ;BDOS/MEX print-string function call
  90.  
  91.     ENDIF            ;MEXOVL
  92.  
  93. BELL    EQU    07H        ;bell
  94. CR    EQU    0DH        ;carriage return
  95. ESC    EQU    1BH        ;escape
  96. LF    EQU    0AH        ;linefeed
  97.  
  98. YES    EQU    0FFH
  99. NO    EQU    0
  100.  
  101.     org    0100h
  102.  
  103.         DS    3    ;for 3 byte jump instruction
  104.  
  105. PMMIMODEM:    DB    NO    ;yes=PMMI S-100 Modem            103H
  106. SMARTMODEM:    DB    no    ;yes=HAYES Smartmodem, no=non-PMMI    104H
  107. TOUCHPULSE:    DB    'T'    ;T=touch, P=pulse (Smartmodem-only)    105H
  108. CLOCK:        DB    40    ;clock speed in MHz x10, 25.5 MHz max.    106H
  109.                 ;20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  110. MSPEED:        DB    1    ;0=110 1=300 2=450 3=600 4=710 5=1200    107H
  111.                 ;6=2400 7=4800 8=9600 9=19200 default
  112. BYTDLY:        DB    5    ;0=0 delay  1=10ms  5=50 ms - 9=90 ms    108H
  113.                 ;default time to send character in ter-
  114.                 ;minal mode file transfer for slow BBS.
  115. CRDLY:        DB    5    ;0=0 delay 1=100 ms 5=500 ms - 9=900 ms 109H
  116.                 ;default time for extra wait after CRLF
  117.                 ;in terminal mode file transfer
  118. NOOFCOL:    DB    5    ;number of DIR columns shown        10AH
  119. SETUPTST:    DB    YES    ;yes=user-added Setup routine        10BH
  120. SCRNTEST:    DB    YES     ;Cursor control routine         10CH
  121. ACKNAK:        DB    no     ;yes=resend a record after any non-ACK    10DH
  122.                 ;no=resend a record after a valid-NAK
  123. BAKUPBYTE:    DB    NO    ;yes=change any file same name to .BAK    10EH
  124. CRCDFLT:    DB    YES    ;yes=default to CRC checking        10FH
  125. TOGGLECRC:    DB    YES    ;yes=allow toggling of CRC to Checksum    110H
  126. CONVBKSP:    DB    NO    ;yes=convert backspace to rub        111H
  127. TOGGLEBK:    DB    YES    ;yes=allow toggling of bksp to rub    112H
  128. ADDLF:        DB    NO    ;no=no LF after CR to send file in    113H
  129.                 ;terminal mode (added by remote echo)
  130. TOGGLELF:    DB    YES    ;yes=allow toggling of LF after CR    114H
  131. TRANLOGON:    DB    NO    ;yes=allow transmission of logon    115H
  132.                 ;write logon sequence at location LOGON
  133. SAVCCP:        DB    YES    ;yes=do not overwrite CCP        116H
  134. LOCONEXTCHR:    DB    NO    ;yes=local command if EXTCHR precedes    117H
  135.                 ;no=external command if EXTCHR precedes
  136. TOGGLELOC:    DB    YES    ;yes=allow toggling of LOCONEXTCHR    118H
  137. LSTTST:        DB    NO    ;yes=printer available on printer port    119H
  138. XOFFTST:    DB    NO    ;yes=checks for XOFF from remote while    11AH
  139.                 ;sending a file in terminal mode
  140. XONWAIT:    DB    NO    ;yes=wait for XON after CR while    11BH
  141.                     ;sending a file in terminal mode
  142. TOGXOFF:    DB    YES    ;yes=allow toggling of XOFF checking    11CH
  143. IGNORCTL:    DB    no    ;yes=CTL-chars above ^M not displayed    11DH
  144. EXTRA1:        DB    0    ;for future expansion            11EH
  145. EXTRA2:        DB    0    ;for future expansion            11FH
  146. BRKCHR:        DB    '@'-40H    ;^@ = Send 300 ms. break tone        120H
  147. NOCONNCT:    DB    'N'-40H    ;^N = Disconnect from the phone line    121H
  148. LOGCHR:        DB    'L'-40H    ;^L = Send logon            122H
  149. LSTCHR:        DB    'P'-40H    ;^P = Toggle printer            123H
  150. UNSAVE:        DB    'R'-40H    ;^R = Close input text buffer        124H
  151. TRANCHR:    DB    'T'-40H ;^T = Transmit file to remote        125H
  152. SAVECHR:    DB    'Y'-40H    ;^Y = Open input text buffer        126H
  153. EXTCHR:        DB    '^'-40H    ;^^ = Send next character        127H
  154. ;
  155.         DS    2        ;                128H
  156. ;
  157. ; The following table is over written by the SETBAUD routine upon initialization
  158. ; and is only here for address reference.
  159.  
  160. IN$MODCTL1:    IN    29H        ; CONTROL PORT
  161.         RET
  162.         DS    7
  163. otdata:        OUT    28H        ; OUTPUT TO DATA PORT   
  164.         RET
  165.         DS    7
  166. inport:        JMP    PORTAI        ; INPUT FROM DATA PORT
  167.         DS    7
  168. maskr:        JMP    ANIRCB        ; RCV READY MASK
  169. testr:        JMP    CPIRCR        ; RCV READY VALUE
  170. masks:        JMP    ANISNB        ; XMIT READY MASK
  171. tests:        JMP    CPISNR        ; XMIT READY VALUE
  172.  
  173.         DS    6
  174.  
  175. OUT$MODCTL1:    RET            ;out modem control port #2    15AH
  176.         DS    2
  177. OUT$MODCTL2:    RET            ;out modem control port #1    15DH
  178.         DS    2
  179.  
  180. LOGONPTR:    DW    LOGON        ;for user message.        160H
  181.         DS    3        ;DIALV: not done here (maybe MXO-SM)162H
  182. DISCV:        JMP    DISCON        ;disconnect
  183. JMP$GOODBYE:    JMP    GOODBYE        ;                168H
  184. JMP$INITMOD:    JMP    INITMOD        ;go to user written routine    16BH
  185.         NOP            ; New Baud Rate            16EH
  186.         NOP
  187.         RET
  188.         NOP  
  189.         NOP            ; Set no Parity            171H
  190.         RET  
  191.         NOP  
  192.         NOP            ; Set Parity            174H
  193.         RET
  194.     
  195. JMP$SETUPR:    JMP    SETUPR        ; following not used by MEX:    177H
  196. JMP$SPCLMENU:    JMP    SPCLMENU    ;                17AH
  197. JMP$SYSVER:    JMP    sysver        ;                17DH
  198. JMP$BREAK:    JMP    SENDBRK        ;                180H
  199.  
  200. ; Do not change the following six lines (they provide access to routines
  201. ; in MEX that are present to support MDM7 overlays -- they will likely
  202. ; be gone by MEX v2.0).
  203.  
  204. JMP$ILPRT:    DS    3        ;                183H
  205. JMP$INBUF:    DS    3        ;                186H
  206. JMP$INLNCOMP:    DS    3        ;                189H
  207. JMP$INMODEM:    DS    3        ;                18CH
  208. JMP$NXTSCRN:    DS    3        ;                18FH
  209. JMP$TIMER:    DS    3        ;                192H
  210.  
  211. ; Routine to clear to end of screen.  If using CLREOS and CLRSCRN, set
  212. ; SCRNTEST to YES at 010AH (above).
  213.  
  214.         IF    MEXOVL
  215.  
  216. CLREOS:        LXI    D,EOSMSG    ;                195H
  217.         MVI    C,PRINT
  218.         CALL    MEX
  219.         RET
  220. ;
  221. CLRSCRN:    LXI    D,CLSMSG    ;                19EH
  222.         MVI    C,PRINT
  223.         CALL    MEX
  224.         RET
  225.  
  226. EOSMSG:        DB    07EH,018H,'$'
  227. CLSMSG:        DB    07EH,01CH,'$'
  228.  
  229.           ENDIF
  230.  
  231.         IF     NOT MEXOVL
  232.  
  233. CLREOS:        CALL    JMP$ILPRT    ;                195H
  234.         DB    07EH,018H,0,0,0 ;                198H
  235.         RET            ;                19DH
  236. ;
  237. CLRSCRN:    CALL    JMP$ILPRT    ;                19EH
  238.         DB    07EH,01CH,0,0,0 ;                1A1H
  239.         RET            ;                1A6H
  240.     
  241.         ENDIF            ; if NOT MEXOVL
  242.  
  243. SYSVER:        RET            ; version number is provided by SETBAUD
  244.  
  245. SENDBRK:    RET
  246.  
  247. ; Disconnect the modem
  248.  
  249. ; if on onboard modem, bring onhook. Presently not configured for any
  250. ; particular type of modem. Future release may have this patched.
  251.  
  252. DISCON:    RET
  253.  
  254. ; You can put in a message at this location which can be called up with
  255. ; CTL-O if TRANLOGON has been set TRUE.  You can use several lines if
  256. ; desired.  End with a 0.
  257. ;
  258. LOGON:        DB    0
  259.  
  260. ; Add your own routine here to put DTR low and/or send a break tone.
  261. ; Check other routines such as MDM709DP.ASM which is using this feature.
  262.  
  263. GOODBYE:CALL    FIXUP        ; return interrupt vector to original condition
  264.     RET
  265.  
  266. ; Before exiting or entering SETUP, call FIXUP to install the original
  267. ; modem/DUAL serial card interrupt vector at FB0CH
  268.  
  269. FIXUP:    LDA    PORTID
  270.     CPI    1
  271.     RZ
  272.     CPI    3
  273.     RZ
  274.     LHLD    INTSAVE            ; reset interrupt vector
  275.     SHLD    0FB0CH
  276.     RET
  277.  
  278. ; The following is called by the SET command
  279.  
  280. SETUPR:    CALL    SETBAUD
  281.     RET
  282.  
  283. ; Before doing any modem I/O, the following routine is called to
  284. ; initialize any modem related parameters - such as baud rate or
  285. ; which port is to be used in modeming.
  286.  
  287. INITMOD: CALL    SETBAUD
  288.      RET
  289.  
  290. ; Routines specific to the Pied Piper's modem and serial card. The following
  291. ; code initializes these cards with info given by the user - such as baud
  292. ; rate,etc. Before MDM is started, Port A or port B may be selected. To
  293. ; re-select the baud rate, the program must be restarted.
  294.  
  295.  
  296. PRTSTR  EQU     9           ; BDOS PRINT STRING
  297. DIRIO   EQU     6           ; DIRECT CONSOLE I/O
  298. INPUT   EQU     0FFH        ; DIRECT CONSOLE INPUT
  299.  
  300. AZERO   EQU     '0'-1         ; first ascii code that is LT zero
  301. ASIX    EQU     '9'+1         ; FIRST ASCII CODE THAT IS GT NINE
  302. BKSPACE EQU     8           ; BACKSPACE CODE
  303.  
  304. DECOFF  EQU     '0'         ; OFFSET TO CHANGE TO DECIMAL
  305. NOTFOUND EQU    0FFH        ; INPUT ERROR, BAUDRATE NOT FOUND
  306.  
  307. TCNT    EQU     0B7H        ; TIMER CONTROL
  308. PORT1   EQU     3BH         ; TIMER CONTROL PORT
  309. CTR2       EQU     3AH         ; COUNTER TWO
  310. CTR1    EQU    39H        ; COUNTER ONE
  311. CTR0    EQU    38H        ; COUNTER ZERO
  312.  
  313. COMMU    EQU    0FAF6H        ; BIT 7 - 4 = 0101 -- MODEM CARD
  314.                 ; BIT 7 - 4 = 1010 -- SERIAL CARD
  315.  
  316. SETBAUD:LXI    D,IDMSG            ; PRINT OUT SIGNON MESSAGE
  317.     MVI    C,PRTSTR
  318.     CALL    BDOS
  319.     LDA    COMMU            ; CHECK IF SYSTEM HAS EXPANSION
  320.     ANI    0F0H            ; CARD CONFIGURED
  321.     XRI    0F0H            ; NOT ALLOW IF NOT
  322.     JNZ    SYSCNF
  323.     LXI    D,ERMSG
  324.     MVI    C,PRTSTR
  325.     CALL    BDOS
  326.     POP    H
  327.     POP    D
  328.     POP    B
  329.     POP    PSW
  330.     JMP    0
  331. SYSCNF:
  332.          LXI    D,PORT                  ; ASK FOR PORT TO USE
  333.          MVI    C,PRTSTR
  334.          CALL   BDOS
  335.  
  336. GETPOR:  MVI    C,DIRIO                  ; DIRECT CONSOLE I/O
  337.          MVI    E,INPUT                  ; INPUT
  338.          CALL   0005h
  339.  
  340.          ORA    A                         ; IF NO INPUT THEN GET ANOTHER INPUT
  341.          JZ    GETPOR
  342.      ANI    07FH                  ; RES 7,A
  343.      CPI    3
  344.      JZ    0
  345.      ANI    05FH                  ; CHANGE TO UPPER CASE
  346.      CPI    'A'
  347.      JC    GETPOR            ; ask again if char < A
  348.          CPI     'E'
  349.          JNC    GETPOR                ; GET ANOTHER INPUT if not A-D
  350. ECOPOR:
  351.          PUSH   PSW                    ; SAVE INPUT
  352.  
  353.          MOV    E,A                      ; ECHO INPUT STRING
  354.          MVI    C,DIRIO                  ; USE DIRECT CONSOLE I/O
  355.          CALL   BDOS
  356.  
  357.          MVI    E,BKSPACE                ; BACKSPACE
  358.          MVI    C,DIRIO                  ; USING DIRECT CONSOLE I/O
  359.          CALL   BDOS
  360.  
  361.         POP    PSW                  ; GET SAVED INPUT
  362.     SUI    'A'
  363.     STA    PORTID            ; SAVE PORT ID
  364.     LDA    COMMU            ; CHECK IF SERIAL CARD
  365.     ANI    0F0H
  366.     CPI    050H
  367.     JNZ    GETBAU1            ; ASK FOR BAUD RATE IF SERIAL CARD
  368.     LDA    PORTID            ; MODEM CARD, CHECK IF PORT B
  369.     CPI    1
  370.     JZ    INIVEC            ; SKIP BAUD RATE SINCE 300 FIXED
  371.     CPI    3
  372.     JZ    GETBAU2            ; Port B of Dual Serial is not 
  373.                     ; interrupt driven, so skip
  374.  
  375. ; ++++++++ install the new interrupt vectors for RS-232 USART A's +++++++++
  376.  
  377. GETBAU1:LHLD    0FB0CH        ; save old interrupt vector for GOODBYE
  378.     SHLD    INTSAVE
  379.     LXI    H,INTR            ; address of interrupt routine
  380.     SHLD    0FB0CH            ; and initialize the new interrupt vector
  381. GETBAU2:MVI    A,0
  382.     STA    buflen            ; indicate no char waiting in queue
  383.  
  384. GETBAU:
  385.          LXI    D,MESS                  ; DISPLAY MESSAGE
  386.          MVI    C,PRTSTR
  387.          CALL   BDOS
  388.  
  389. READIN:  MVI    C,DIRIO                  ; DIRECT CONSOLE I/O
  390.          MVI    E,INPUT                  ; INPUT
  391.          CALL   BDOS
  392.  
  393.          ORA    A                        ; IF NO INPUT THEN GET ANOTHER INPUT
  394.          JZ    READIN
  395.      ANI    07FH                 ; RES 7,A
  396.      CPI    3
  397.      JZ    0            ; return if control C pressed
  398.          CPI     AZERO                    ; IF LESS THAN OR EQUAL TO ZERO
  399.          JC     READIN                 ; GET ANOTHER INPUT
  400.          CPI     ASIX                     ; IF GREATER THAN NINE
  401.          JNC     READIN                ; GET ANOTHER INPUT
  402.  
  403.          PUSH   PSW                       ; SAVE INPUT
  404.  
  405.          MOV    E,A                      ; ECHO INPUT STRING
  406.          MVI    C,DIRIO                  ; USE DIRECT CONSOLE I/O
  407.          CALL   BDOS
  408.  
  409.          MVI    E,BKSPACE                ; BACKSPACE
  410.          MVI    C,DIRIO                  ; USING DIRECT CONSOLE I/O
  411.          CALL   BDOS
  412.  
  413.          POP    PSW                       ; GET SAVED INPUT
  414.          SUI    DECOFF                   ; CHANGE TO DECIMAL 
  415.          LXI    H,BDRATE                 ; GET ADDRESS THAT STORES BAUDRATE BY
  416.      DB    0CBH                 ; Z80 'SLA A' instruction
  417.      DB    027H                 ; Multiplt input by two
  418.          MOV    E,A                      ; STORE IN REG. E
  419.          MVI    D,0                      ; CLEAR REG. D
  420.          DAD    D                        ; GET ADDRESS FOR CORRECT BAUDRATE
  421.  
  422.          MOV     E,M                    ; GET REQUIRED BAUDRATE
  423.          INX     H                      ; GET BAUDRATE IN REG. PAIRS DE
  424.          MOV     D,M
  425. ;
  426. ;    IF SERIAL CARD AND PORT A - INIT CTR 1 AND CTR 0
  427. ;    IF SERIAL CARD AND PORT B - INIT CTR 2
  428. ;    IF MODEM CARD AND PORT A - INIT CTR0
  429.  
  430.     LDA    PORTID            ; GET PORT SELECTED
  431.     CPI    00
  432.     JZ    OK
  433.     CPI    2
  434.     JNZ    SETB
  435.  
  436. OK:    MVI    A,00110111B               ; SELECT COUNTER 0
  437.     OUT    PORT1                   ; SEND TO CONTROL PORT
  438.  
  439.         MOV     A,E                       ; GET BAUDRATE AND SEND TO COUNTER
  440.         OUT    CTR0
  441.         MOV     A,D
  442.         OUT    CTR0
  443.  
  444. CONT:    LDA    COMMU            ; CHECK IF MODEM CARD
  445.     ANI    0F0H
  446.     CPI    050H            ; SKIP  AND SET UP VECTORS
  447.     JZ    INIVEC
  448.     MVI    A,01110111B        ; SELECT COUNTER 1
  449.     OUT    PORT1
  450.     MOV    A,E
  451.     OUT    CTR1
  452.     MOV    A,D
  453.     OUT    CTR1
  454.     JMP    INIVEC
  455. SETB:
  456.     MVI    A,10110111B        ; SELECT COUNTER 2
  457.     OUT    PORT1
  458.     MOV    A,E
  459.     OUT    CTR2
  460.     MOV    A,D
  461.     OUT    CTR2
  462. ;
  463. ;    SET UP INSTAT, OUTSTA, INDATA, OUTDAT VECTORS
  464. ;
  465. INIVEC:    LXI    H,PORTBV        ; POINT TO PORT B VECTORS
  466.     LDA    PORTID
  467.     CPI    3
  468.     JZ    SETVEC            ; DUAL B not interrupt driven
  469.     CPI    1
  470.     JZ    SETVEC            ; Select Onboard Modem port
  471.     LXI    H,PORTAV        ; POINT TO PORT A VECTORS
  472. SETVEC:    LXI    D,IN$MODCTL1
  473.     LXI    B,42
  474.     DB    0EDH            ; Z80 LDIR instruction
  475.     DB    0B0H
  476.     
  477. MDMIRT:  LXI    D,CRLF                  ; DISPLAY CRLF
  478.          MVI    C,PRTSTR
  479.          CALL   BDOS
  480.  
  481.      IF    MEXOVL
  482.      LXI    D,CRLF
  483.      MVI    C,PRTSTR
  484.      CALL    BDOS
  485.      ENDIF
  486.  
  487.      mvi    a,0
  488.      sta    new
  489.      sta    old
  490.      sta    buflen
  491.      RET
  492.  
  493. BDOS:    IF    MEXOVL
  494.     JMP    MEX
  495.     ENDIF
  496.  
  497.     IF     NOT MEXOVL
  498.     JMP    0005h 
  499.     ENDIF
  500.  
  501.  
  502. ; RS-232 USART interrupt routine (Port B's have no interrupts)
  503.  
  504. INTR:    di            ; stop USART from interrupting us!
  505.      DB    0EDH        ; LD (STKSAV),SP
  506.      DB    073H
  507.      dw    stksav
  508.      lxi    sp,stack
  509.          push    psw
  510.      push    d
  511.      push    h
  512.      lda    buflen        ; how many characters are in the queue?
  513.      cpi    length        ; is buffer full?
  514.      jnz    notdone
  515.      call    input1        ; clear the RxRDY interrupt line
  516.      jmp    rtn
  517.  
  518. notdone: inr    a        ; add another character to the queue
  519.      sta    buflen
  520.      lxi    h,buffer
  521.  
  522.      lda    new        ; get current position
  523.      mov    e,a
  524.      mvi    d,0
  525.      inr    a
  526.      cpi    length        ; are we at end of the queue?
  527.      jnz    nol
  528.      mvi    a,0
  529. nol:     sta    new        ; store away for next retreival
  530.      dad    d
  531.      call    input1
  532.      mov    m,a
  533. rtn:     pop    h
  534.      pop    d
  535.      pop    psw
  536.      DB    0EDH
  537.      DB    07BH
  538.      DW    STKSAV
  539.          ei            ; and let USART B interrupt us some more
  540.          ret    
  541.  
  542. input1:     lda    portid
  543.      cpi    3        ; is port Dual Serial Port board Port B?
  544.      jnz    inprta        ; no, go input normally
  545.      in    02ah        ; get serial Port B input
  546.      ret
  547.  
  548. inprta:     IN    028H        ; get data from RS-232 USART
  549.      ret
  550.  
  551. ;    ----------- PORT A I/O ROUTINES --------------
  552.  
  553. ANISNB:    RET
  554.  
  555. CPISNR:    LDA    PORTID
  556.     CPI    3
  557.     JNZ    IN29
  558.     IN    02BH            ; get serial Port B input
  559.     JP    CHECK
  560.  
  561. IN29:    IN    29H
  562.  
  563. CHECK:    ANI    01
  564.     CPI    01
  565.     RET
  566.  
  567. ANIRCB:    RET
  568.  
  569. CPIRCR:    LDA    buflen
  570.     CPI    0        ; is data waiting?
  571.     jz    yes0
  572.     mvi    a,0        ; ret with zero set
  573.     ora    a
  574.     ret
  575. yes0:    mvi    a,0ffh        ; ret with zero not set
  576.     ora    a
  577.     ret
  578.  
  579. PORTAI:    push    h
  580.     push    d
  581.     lda    buflen
  582.     cpi    0
  583.     jz    nochar
  584.     lxi    h,buflen    ; *** Because the INTR routine is running in
  585.     db    035h        ; INC (HL) - the background we must dec the
  586.                 ; buffer count in one instruction to prevent
  587.                 ; the intr routine from inc. the buffer counter
  588.                 ; while we are accessing buflen.
  589.  
  590.     lda    old        ; get old position within the queue
  591.     mov    e,a
  592.     mvi    d,0
  593.     lxi    h,buffer
  594.     dad    d
  595.     inr    a
  596.     cpi    length
  597.     jnz    nol2
  598.     mvi    a,0
  599. nol2:    sta    old
  600.     mov    a,m
  601.     pop    d
  602.     pop    h 
  603.     ret
  604.  
  605. nochar: mvi    a,0
  606.     ret
  607.  
  608. ;     ------- End of PORT A SERIAL Routines --------------
  609.  
  610. ; 300 baud modem I/O jumps (or Dual Card's Port B Serial RS-232 Port B)
  611.  
  612. PORTBV:    IN    02BH        ; CONTROL PORT
  613.     RET
  614.     DS    7
  615.     OUT    2AH        ; OUTPUT TO DATA PORT
  616.     RET
  617.     DS    7
  618.     IN    2AH        ; INPUT FROM DATA PORT
  619.     RET
  620.     DS    7
  621.     ANI    02        ; RCV READY MASK
  622.     RET
  623.     CPI    02        ; RCV READY VALUE
  624.     RET
  625.     ANI    01        ; XMIT READY MASK
  626.     RET
  627.     CPI    01        ; XMIT READY VALUE
  628.     RET
  629.  
  630. ; Serial I/O jumps
  631.  
  632. PORTAV:    IN    29H        ; CONTROL PORT
  633.     RET
  634.     DS    7
  635.     OUT    28H        ; OUTPUT TO DATA PORT   ***** not for DUAL B
  636.     RET
  637.     DS    7
  638.     JMP    PORTAI        ; INPUT FROM DATA PORT
  639.     DS    7
  640.     JMP    ANIRCB        ; RCV READY MASK
  641.     JMP    CPIRCR        ; RCV READY VALUE
  642.     JMP    ANISNB        ; XMIT READY MASK
  643.     JMP    CPISNR        ; XMIT READY VALUE
  644.  
  645. IDMSG:    DB    CR,LF
  646.     DB    'Installed for STM Pied Piper  (Beta Rel. '
  647.     db    mainver+'0',' vers ',vers/10+'0','.',vers mod 10+'0'
  648.     db    ' - ',month/10+'0',month mod 10+'0','/',day/10+'0'
  649.     db    day mod 10 +'0','/',year/10+'0'
  650.     db    year mod 10 +'0',')'
  651.     db '$' 
  652.  
  653. ERMSG:    DB    CR,LF,LF
  654.     DB    'No expansion card configured on current system,'
  655.     DB    CR,LF,'please run CONFIG.COM release 2.02 or later.'
  656.     db     '$' 
  657.  
  658. PORT:    DB    CR,LF,LF
  659.     DB    'Select Port to use:...',cr,lf,LF
  660.     DB    '   A. Interrupt driven Serial Port A of Modem Card.',cr,lf
  661.     DB    '   B. 300 Baud Modem of Modem Card..',cr,lf
  662.     DB    '   C. Interrupt driven Port A of Dual Serial Card..',cr,lf
  663.     DB    '   D. Port B of Dual Serial Card..',cr,lf,lf
  664.         DB         'Enter selection: '
  665.     db     '$' 
  666.  
  667. MESS:    DB     CR,lF,LF
  668.         DB     'Baud rate selection:...'
  669.     DB    CR,LF
  670.         DB         CR,LF,'   0.   110 BAUD..'
  671.     DB    CR,LF,'   1.   150 BAUD..'
  672.         DB         CR,LF,'   2.   300 BAUD..'
  673.     DB    CR,LF,'   3.   450 BAUD..'
  674.     DB    CR,LF,'   4.   600 BAUD..'
  675.         DB         CR,LF,'   5.  1200 BAUD..'
  676.         DB         CR,LF,'   6.  2400 BAUD..'
  677.         DB         CR,LF,'   7.  4800 BAUD..'
  678.         DB         CR,LF,'   8.  7200 BAUD..'
  679.         DB         CR,LF,'   9.  9600 BAUD..'
  680.         DB         CR,LF,LF,'Enter selection: '
  681.     db     '$' 
  682.  
  683. CRLF:        DB    CR,LF
  684.         db     '$' 
  685.  
  686. ; To select the baudrate, BCD = 2,000,000/16/baudrate
  687.  
  688. ; PLACE TO STORE BAUDRATE
  689.  
  690. BDRATE: DW    01136H            ; 110 baud
  691.     DW    0833H            ; 150 baud
  692.     DW         0417H                   ; 300  baud
  693.     DW    0278H            ; 450  baud  
  694.     DW    0208H            ; 600  baud
  695.         DW         0104H            ; 1200 baud
  696.         DW         0052H            ; 2400 baud
  697.         DW         0026H            ; 4800 baud
  698.     DW    0017H            ; 7200 baud
  699.         DW         0013H            ; 9600 baud
  700.  
  701. portid:    db    00        ; which port the user has picked (0-3)
  702.  
  703. intsave:dw    0000        ; old interrupt vector storage
  704.  
  705. stksav:    dw    0000        ; interrupt routine stack save storage
  706.  
  707. new:    db    00        ; next location for input character
  708.  
  709. old:    db    00        ; next location to get character FROM
  710.  
  711. buflen:    db    00        ; # of characters presently in the queue
  712.  
  713. length    equ    0FEH        ; length of the interrupt buffer
  714.  
  715. buffer:    ds    length        ; 10 character interrupt character buffer
  716.  
  717.     ds    60H        ; stack space (could be 20, but who cares really?)
  718.  
  719. stack    equ    $-1
  720.  
  721. SPCLMENU:  RET
  722.  
  723. ; NOTE:  MUST TERMINATE PRIOR TO 0B00H  to be used with smartmodem.
  724.  
  725.      END
  726.  
  727.