home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / mex / mxo-rs21.asm < prev    next >
Encoding:
Assembly Source File  |  1994-07-13  |  24.8 KB  |  787 lines

  1. ;   Title    'MEX overlay for the TRS-80 MOD IV version 2.1'    
  2. ;                      Montezuma Micro CP/M 2.2
  3. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  4. ; MEX TRS-80 MOD IV OVERLAY VERSION 1.0: Written 09/10/84 by Ed Richter 
  5. ;
  6. ; VERSION 2.1 08/06/86 - Correct modem control to properly handle changes
  7. ;             in word length, parity, and stop bits.  Changes
  8. ;             to these parameters by the SET command were never
  9. ;             communicated to the UART.
  10. ;
  11. ; VERSION 2.0 10/06/85 - Change to the printer status routine.  Now
  12. ;             checks all four possible printer states.
  13. ;             Ver.114 changed ^C address from AUTO ANSWER.
  14. ;             Added code at STANS to find the correct 
  15. ;             address.
  16. ;                            Ed Richter 
  17. ;                        71455,1133
  18. ; VERSION 1.9 09/12/85 - Minor change to eliminate some un-necessay
  19. ;             code when using the AUTO ANSWER mode. See
  20. ;             NOMXOSM.
  21. ;                        Ed Richter
  22. ; VERSION 1.8 05/05/85 - Included the changes from the file 
  23. ;             MXO-RS17.FIX. The baud rate detect now works.
  24. ;                        Ed Richter
  25. ; VERSION 1.7 01/25/85 - ^C in "auto-answer now aborts to CPM, not
  26. ;             MEX.(sorry bout that one) Added code to
  27. ;             determine baud rate in "auto-answer".
  28. ;             Changed "NITMOD" to default  to the baud 
  29. ;             rate selected by "MSPEED"     
  30. ;                        Ed Richter
  31. ; VERSION 1.6 01/21/85 - A system reset seems a little drastic
  32. ;                        so added code for a ^C abort to auto
  33. ;              answer. Also added "number of rings" 
  34. ;             equate.
  35. ;                         Ed Richter
  36. ; VERSION 1.5 11/17/84 - Added SET ANSWER ON command
  37. ;             (For Hayes-compatible modems
  38. ;              only...see NOTE below.)
  39. ;                        Thom Foulks
  40. ; VERSION 1.3 10/10/84 - Fixed bug in the Printer ready test
  41. ;                                                 Ed Richter
  42. ; VERSION 1.2 09/18/84 - Added the comments to 1.1 and changed the
  43. ;             configuration of the SET message that is
  44. ;             output to the console
  45. ;                           Ed Richter 
  46. ; VERSION 1.1 09/16/84 - Added code to fully control the SIO USART
  47. ;                 via the SET command. This overlay now 
  48. ;             supports-- SET BAUD -- SET PARITY --
  49. ;             SET STOP BITS -- SET WORD LENGTH --
  50. ;                                                   Ed Richter
  51. ; This file was derived from the MDM7xx overlay M7R4-5.ASM, and the 
  52. ; file MXOPM10.ASM. It is a MEX overlay for use with the TRS-80 MOD
  53. ; IV, and an external modem. It has a SET command that supports 300
  54. ; though 9600 baud.
  55. ;
  56. ; The SMARTMODEM, and compatibles will answer the phone at the
  57. ; incoming caller's baud rate .This makes it necessary to insure
  58. ; that the SIO-USART is configured to the same speed. This progam
  59. ; will answer the phone at the MSPEED baud rate. If it cannot
  60. ; read characters at that speed it will start at 110 baud (BAUD vector 
  61. ; set to 0), check for a CR, LF, or ^C. If it is unable to read a
  62. ; character at that speed it will increment the baud rate to 1200
  63. ; (the - CPI '6' - in the TSTBAUD routine), and retry at each step.
  64. ; To change the upper limit (1200) change the  CPI '6' to the MSPEED
  65. ; value +1. ie., CPI '10' for 19200.
  66. ;
  67. ; NOTE: This overlay must be used in congunction with MXO-SM11.ASM
  68. ; for full modem control.  The SET ANSWER command will place MEX
  69. ; into an auto-answer mode which may be exited prior to execution
  70. ; with a ^C - CONTROL C -  it's intended for use with a READ file
  71. ; similar to Bruce Morgen's WELCOME3 or WELCOME4.
  72. ;                                      - Thom Foulks
  73. ;
  74. ; Rev 19 Note: If you are using a SMARTMODEM and MXO-SMxx.ASM, the
  75. ; SMSEND and DISCON routines in this overlay can be deleted. Use
  76. ; matching one's in MXOSMxx.ASM  by deleting the END statement
  77. ; for this overlay, and appending the SMARTMODEM overlay to this one.
  78. ; Assemble both as 1 file and load the resulting HEX file to MEX.COM
  79. ;                    - Ed Richter 
  80. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  81. REV:         EQU    21
  82. ;
  83. CR:        EQU    0DH    ;carriage return
  84. LF:        EQU    0AH    ;linefeed
  85. ONV:        EQU    0FH    ;reverse video on
  86. INV:        EQU    0EH    ;reverse video off
  87. TPA:        EQU    0100H    ;start of program
  88. TAB:        EQU    09H    
  89. YES:        EQU    0FFH    ;true
  90. NO:        EQU    0    ;not true
  91. RING:        EQU    '2'    ;number of rings for auto-answer
  92. ;
  93. NOMXOSM:    EQU    YES    ;NO =  MXO-SMxx.ASM appended to this file. 
  94. ;
  95. ; NOTE..If you are using the DISC equate in MXO-SMxx.ASM set to NO for
  96. ;       disconnect with DTR, then this equate must be set to YES.
  97. ;       This equate, if used, will save the space used for the DTR 
  98. ;    DISCON, and the SMSEND routines used in this overlay.  
  99. ;
  100. ; Change the following information to match your equipment.
  101. ; PORT should be set to the base port address for the RS-232 port.
  102. ;
  103. PORT:        EQU    0E8H    ;master reset port   
  104. MODCT1:        EQU    PORT+2    ;modem control port
  105. MODDAT:        EQU    PORT+3    ;modem data in port
  106. MODCT2:        EQU    PORT+2    ;not used mod iv
  107. BAUDRP:        EQU    PORT+1    ;baud rate port
  108. MDRCVB:        EQU    080H    ;bit to test for receive
  109. MDRCVR:        EQU    080H    ;value when ready
  110. MDSNDB:        EQU    040H    ;bit to test for send
  111. MDSNDR:        EQU    040H    ;value when ready
  112.  
  113. ;
  114. ; UART Control Bit Configuration
  115. ;
  116. U$WRD5:        EQU    000H    ;Word length of 5 bits
  117. U$WRD6:        EQU    040H    ;Word length of 6 bits
  118. U$WRD7:        EQU    020H    ;Word length of 7 bits
  119. U$WRD8:        EQU    060H    ;Word length of 8 bits
  120. U$PRON:        EQU    000H    ;Parity ON
  121. U$PROF:        EQU    008H    ;Parity OFF
  122. U$PREV:        EQU    080H    ;Parity EVEN
  123. U$PROD:        EQU    000H    ;Parity ODD
  124. U$STP1:        EQU    000H    ;Stop bits 1
  125. U$STP2:        EQU    010H    ;Stop bits 2
  126. U$XMIT:        EQU    004H    ;Set to enable transmit
  127. U$RTS:        EQU    002H    ;Set for RTS
  128. U$RTSO:        EQU    000H    ;Clear to turn on RTS
  129. U$DTR:        EQU    001H    ;Set for DTR off
  130. U$DTRO:        EQU    000H    ;Clear to turn on DTR
  131. ;
  132. ;    Default UART configurations and bit masks
  133. ;
  134. DEFCTB:        EQU    U$PROF+U$PREV+U$WRD8+U$STP1+U$DTRO+U$XMIT+U$RTSO
  135. DFBAUD:        EQU    6    ;0=110 1=300 2=450 3=600 4=710 5=1200    
  136.                 ;6=2400 7=4800 8=9600 9=19200 default
  137. DFBAUD:        EQU    6        ;Default start speed (6=2400)
  138. CTSMSK:        EQU    020H        ;carrier detect mask
  139. ISOCD:        EQU    0DFH        ;port ready mask
  140. PRPORT:        EQU    0F8H        ;printer port
  141. PRSTAT:        EQU    0F0H        ;printer ready mask
  142. BRKMSK:        EQU    0FFH-U$XMIT    ;send break
  143. DTRMSK:        EQU    0FFH-U$DTR-U$RTS ;drop dtr
  144.  
  145. ;
  146. ;MEX SERVICE PROCESSOR STUFF
  147. ;
  148. MEX:        EQU    0D00H    ;address of the service processor
  149. INMDM:        EQU    255    ;get char from port,CY=no more in 100ms
  150. TIMER:        EQU    254    ;delay 100 ms * reg b
  151. TMDINP:        EQU    253    ;b=# secs to wait for char,CY=no char
  152. CHEKCC:        EQU    252    ;check for ^C from kbd, Z=present
  153. SNDRDY:        EQU    251    ;test for modem-send ready
  154. RCVRDY:        EQU    250    ;test for modem-receive ready
  155. SNDCHR:        EQU    249    ;send to modem (after SNDRDY)
  156. RCVCHR:        EQU    248    ;recv a char from modem after (RCVRDY)
  157. LOOKUP:        EQU    247    ;table search: see CMDTBL for info 
  158. PARSFN:        EQU    246    ;parse filename from input stream 
  159. BDPARS:        EQU    245    ;parse baud-rate from input stream
  160. SBLANK:        EQU    244    ;scan input stream to next non-blank
  161. EVALA:        EQU    243    ;evaluate numeric from input stream
  162. LKAHED:        EQU    242    ;get nxt char w/o removing from input
  163. GNC:        EQU    241    ;get char from input, CY=1 if none
  164. ILP:        EQU    240    ;inline print
  165. DECOUT:        EQU    239    ;decimal output
  166. PRBAUD:        EQU    238    ;print baud rate
  167. CONOUT:        EQU    2    ;simulated BDOS funct 2:CONSOLE OUT
  168. PRINT:        EQU    9    ;simulated BDOS funct 9: PRINT STRING
  169. INBUF:        EQU    10    ;input buffer, same as BDOS FUNCT 10
  170. ;
  171.         ORG    0D11H    ;install printer ready test
  172.         DW    PRTSTS
  173.         ORG    TPA
  174. ;
  175. ;
  176.         DS    3    ;(for  "JMP   START" instruction)
  177. PMODEM:        DB    NO    ;Not used by MEX            103H
  178. SMODEM:        DB    NO    ;Not used by MEX
  179. TPULSE:        DB    'T'    ;Not used by MEX             105H
  180. CLOCK:        DB    50    ;clock speed in MHz x10, 25.5 MHz max.    106H
  181.                 ;20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  182. MSPEED:        DB    DFBAUD    ;0=110 1=300 2=450 3=600 4=710 5=1200    107H
  183.                 ;6=2400 7=4800 8=9600 9=19200 default
  184. BYTDLY:        DB    0    ;0=0 delay  1=10ms  5=50 ms - 9=90 ms    108H
  185.                 ;default time to send character in ter-
  186.                 ;minal mode file transfer for slow BBS.
  187. CRDLY:        DB    0    ;0=0 delay 1=100 ms 5=500 ms - 9=900 ms 109H
  188.                 ;default time for extra wait after CRLF
  189.                 ;in terminal mode file transfer
  190. COLUMS:        DB    4    ;number of DIR columns shown        10AH
  191. SETFL:        DB    YES    ;yes=user-added Setup routine        10BH
  192. SCRTST:        DB    YES    ;Cursor control routine         10CH
  193.         DS    1    ;reserved (old ACKNAK flag)        10DH
  194. BAKFLG:        DB    YES     ;yes=change any file same name to .BAK    10EH
  195. CRCDFL:        DB    YES    ;yes=default to CRC checking        10FH
  196. TOGCRC:        DB    YES    ;yes=allow toggling of CRC to Checksum    110H
  197. CVTBS:        DB    NO    ;yes=convert backspace to rub        111H
  198. TOGLBK:        DB    YES    ;yes=allow toggling of bksp to rub    112H
  199. ADDLF:        DB    NO    ;no=no LF after CR to send file in    113H
  200.                 ;terminal mode (added by remote echo)
  201. TOGLF:        DB    YES    ;yes=allow toggling of LF after CR    114H
  202. TRNLOG:        DB    NO    ;yes=allow transmission of logon    115H
  203.                 ;write logon sequence at location LOGON
  204. SAVCCP:        DB    YES    ;yes=do not overwrite CCP        116H
  205. LOCNXT:        DB    NO    ;yes=local command if EXTCHR precedes    117H
  206.                 ;no=external command if EXTCHR precedes
  207. TOGLOC:        DB    YES    ;yes=allow toggling of LOCONEXTCHR    118H
  208. LSTTST:        DB    YES    ;yes=allow toggling of printer on/off    119H
  209. XOFTST:        DB    YES    ;yes=checks for XOFF from remote while    11AH
  210.                 ;sending a file in terminal mode
  211. XONWT:        DB    YES    ;yes=wait for XON after CR while    11BH
  212.                 ;sending a file in terminal mode
  213. TOGXOF:        DB    YES    ;yes=allow toggling of XOFF checking    11CH
  214. IGNCTL:        DB    YES    ;yes=CTL-chars above ^M not displayed    11DH
  215. EXTRA1:        DB    0    ;for future expansion            11EH
  216. EXTRA2:        DB    0    ;for future expansion            11FH
  217. BRKCHR:        DB    'K'-40H    ;^K = Send 300 ms. break tone        120H
  218. NOCONN:        DB    'N'-40H    ;^N = Disconnect from the phone line    121H
  219. LOGCHR:        DB    'L'-40H    ;^L = Send logon            122H
  220. LSTCHR:        DB    'P'-40H    ;^P = Toggle printer            123H
  221. UNSVCH:        DB    'R'-40H    ;^R = Close input text buffer        124H
  222. TRANCHR:    DB    'T'-40H ;^T = Transmit file to remote        125H
  223. SAVECHR:    DB    'Y'-40H    ;^Y = Open input text buffer        126H
  224. EXTCHR:        DB    '^'-40h    ;^^ = Send next character        127H
  225.         DS    2
  226. INCTL1:        JMP     STATSND    ;go to "get status"             12AH
  227.         DS    7
  228. OTDATA:        OUT    MODDAT  ! RET    ;out modem data port        134H
  229.         DS    7
  230. INPORT:        IN    MODDAT  ! RET    ;in modem data port
  231.         DS    7
  232. MASKR:        ANI    MDRCVB    ! RET    ;bit to test for receive ready    148H
  233. TESTR:        CPI    MDRCVR    ! RET    ;value of rcv. bit when ready    14BH
  234. MASKS:        ANI    MDSNDB    ! RET    ;bit to test for send ready    14EH
  235. TESTS:        CPI    MDSNDR    ! RET    ;value of send bit when ready    151H
  236.         DS    12        ;unused by MEX
  237. LOGON:        DS    2        ;for user message        160H
  238. DIALV:        DS    3        ;autodial rtn jump        162H
  239. DISCV:        JMP    DISCON        ;disconnect rtn
  240. GOODBV:        DS    3        ;not needed            168H
  241. INMODV:        JMP    NITMOD        ;go to user written routine    16BH
  242. NEWBDV:        JMP    PBAUD        ;set new baud-rate           16EH
  243. NOPARV:        DS    3        ;(by-pass PMMI routine)        171H
  244. PARITV:        DS    3        ;(by-pass PMMI routine)        174H
  245. SETUPV:        JMP    SETCMD        ;initialize USART and modem    177H
  246. SPMENV:        DS    3        ;not used with MEX        17AH
  247. VERSNV:        JMP    SYSVER        ;print header msg        17DH
  248. BREAKV:        JMP    PBREAK        ;send header            180H
  249. ; Do not change the following six lines.
  250. ILPRTV:        DS    3        ;                183H
  251. INBUFV:        DS    3        ;                186H
  252. ILCMPV:        DS    3        ;                189H
  253. INMDMV:        DS    3        ;                18CH
  254. NXSCRV:        DS    3        ;                18FH
  255. TIMERV:        DS    3        ;                192H
  256. ;
  257. ; Routine to clear to end of screen.  If using CLREOS and CLRSCRN, set
  258. ; SCRNTEST to YES at 010AH (above).
  259. ;
  260. CLREOS:        LXI    D,EOSMSG    ;clear to end of screen         195H
  261.         MVI    C,PRINT        ;from cursor
  262.         CALL    MEX        ;                198H
  263.         RET            ;                19DH
  264. ;
  265. CLS:        LXI    D,CLSMSG    ;clear sreen            19EH
  266.         MVI    C,PRINT
  267.         CALL    MEX        ;                1A1H
  268.         RET            ;                1A6H
  269.     
  270. ;
  271. SYSVER:        LXI    D,SOMESG    ;print the sys version msg    1A7H
  272.         MVI    C,PRINT
  273.         CALL    MEX        
  274.         CALL    CRLF        
  275. ;
  276. CARRSH        LXI    D,NOMESG    ;no carrier present msg
  277.         CALL    CARRCK
  278.         MVI    C,PRINT
  279.         CNZ    MEX        ;print if no carrier
  280.         LXI    D,CARMSG    ;carrier present
  281.         MVI    C,PRINT
  282.         CALL    MEX        ;say so and continue
  283.         RET
  284. ;
  285. ; Send a break tone to reset some time-share computers.
  286. ;
  287. PBREAK:        LDA    CURURT        ;Get modem control bits
  288.         ANI    BRKMSK        ;send break
  289.         OUT    MODCT1
  290.           MVI    B,3        
  291.           MVI    C,TIMER
  292.           CALL    MEX        ;delay 300 msec
  293.         LDA    CURURT        ;Get current bits
  294.           OUT    MODCT1
  295.          RET
  296. ;
  297. ; Routine to return status of the modem port
  298. ;
  299. STATSND:    IN    MODCT1        ;in modem contol port
  300.         PUSH     B        ;just in case
  301.         ANI    ISOCD        ;isolate status and clear CD bit
  302.         MOV    B,A        ;save status
  303.         IN     PORT        ;get CD bit
  304.         ANI    CTSMSK        ;isolate CD bit
  305.         ORA    B        ;merge CD with status
  306.         POP    B        ;restore B
  307.         RET
  308. ;
  309. ; This routine will hang up the phone by dropping DTR.
  310. ;*****************************************************************************
  311. ;---THIS CODE IS USED IF NOMXOSM = YES, AND THE MXO-SMxx.ASM OVERLAY
  312. ;---IS SET FOR DISCONNECT WITH DTR, OR A SMARTMODEM IS NOT USED
  313. ;*****************************************************************************
  314. ;
  315.         IF    NOMXOSM
  316. DISCON:          LDA    CURURT        ;Get current modem bits
  317.         ANI    BRKMSK
  318.         ORI    U$DTR+U$RTS    ;Shut off DTR
  319.               OUT    MODCT1        ;send cmd
  320.           MVI    B,5        
  321.           MVI    C,TIMER
  322.           CALL    MEX        ;delay 500 msec
  323.         LDA    CURURT        ;Get current bits
  324.           OUT    MODCT1
  325.           RET
  326.         ENDIF            ;NOMXOSM = YES
  327. ;
  328. ;
  329. ; This area resets the SIO-UART DTR reinitializes all control parameters
  330. ;
  331. NITMOD:          MVI    A,1
  332.           OUT    PORT        ;reset the USART to
  333. SETURT:          LDA    CURURT        ;8,no,1,DTR, and RTS
  334.           OUT    MODCT1
  335.         LXI    H,MSPEED
  336.         MOV    A,M        ;initalize to MSPEED baud rate
  337.         CALL    PBAUD        ;get baud rate
  338.           RET            ;also change the value of MSPEED
  339. ;
  340. ;  Sets the modem speed via the SET COMMAND.
  341. ;
  342. SETCMD:        MVI    C,SBLANK    ;any arguments
  343.         CALL    MEX
  344.         JC    SETSHO        ;if not print out values
  345.         LXI    D,CMDTBL    ;parse commands
  346.         CALL    TSRCH        ;from table
  347.         PUSH    H        ;address on stack
  348.         RNC            ;if yes then execute it
  349.         POP    H        ;no fix stack
  350. SETERR:          LXI    D,SETEMS    ;no then print error
  351.           MVI     C,PRINT
  352.           CALL    MEX
  353.           RET
  354. CMDTBL:        DB    '?'+80H        ;"set ?"
  355.         DW    STHELP
  356.         DB    'BAU','D'+80H    ;"set baud ?'
  357.         DW    STBAUD
  358.         DB    'WOR','D'+80H    ;set word length
  359.         DW    STWORD
  360.         DB    'PARIT','Y'+80H ;set parity
  361.         DW    STPAR
  362.         DB    'STO','P'+80H    ;set stop bits
  363.         DW    STSTOP
  364.                 DB       'ANSWE','R'+80H ;set auto-answer on
  365.         DW    STANS
  366.         DB    0    
  367. SETSHO:        CALL    CLS        ;clear screen
  368.         CALL    SETURT        ;Set up UART control
  369.         CALL    CARRSH        ;carrier present
  370.         LXI    H,SHOTBL    ;show subroutines table
  371. SETSLP:     MOV    E,M        ;get table address
  372.         INX    H
  373.         MOV    D,M
  374.         INX    H
  375.         MOV    A,D        ;end of table
  376.         ORA    E
  377.         RZ            ;exit if yes
  378.         PUSH    H        ;save table pointer
  379.         XCHG            ;addrs to HL
  380.         CALL    GOHL        ;do it
  381.         CALL    CRLF        ;print newline
  382.         MVI    C,CHEKCC    ;check for console abort
  383.         CALL    MEX        
  384.         POP    H        ;its done
  385.         JNZ    SETSLP        ;continue if no abort
  386.         RET
  387. GOHL:        PCHL
  388. SHOTBL:        DW    BDSHOW        ;table
  389.         DW    PARSHOW
  390.         DW    WLSHOW
  391.         DW    STSHOW
  392.         DW    0
  393. STHELP:        LXI    D,HLPMSG    ;print help message
  394.         MVI    C,PRINT
  395.         CALL    MEX
  396.         RET
  397. STBAUD:        MVI    C,BDPARS    ;MEX find baud rate        
  398.         CALL    MEX
  399.         JC     SETERR        ;none then exit
  400.         CALL    PBAUD        ;valid baud rate then set it
  401.         JC     SETERR        ;exit if not supported by overlay
  402. BDSHOW:        CALL    ILPRT
  403.         DB    'Baud Rate:',TAB,' ',0
  404.         LDA    MSPEED        ;get MSPEED to determine present
  405.         MVI    C,PRBAUD    ;baud rate
  406.         CALL    MEX
  407.         RET    
  408. STPAR:        LXI    D,PARTBL    ;find parity function requested
  409.         CALL    TSRCH
  410.         PUSH    H
  411.         RNC            ;execute it
  412.         POP    H
  413.         JMP    SETERR        ;not valid then say so                 
  414. STWORD:        LXI    D,WLTBL        ;find word length function requested
  415.         CALL    TSRCH
  416.         PUSH    H
  417.         RNC            ;execute it
  418.         POP    H
  419.         JMP    SETERR        ;not valid then say so
  420. STSTOP:        LXI    D,STTBL        ;find how many stop bits 
  421.         CALL    TSRCH
  422.         PUSH    H
  423.         RNC            ;execute it
  424.         POP    H
  425.         JMP    SETERR        ;not valid then say so 
  426. STANS:          CALL    CLS        ;clear the screen
  427.         PUSH    H        ;save H
  428.         LXI    H,ANSON        ;get the set command
  429.         CALL    SMSEND        ;send it
  430.         POP    H
  431.         CALL    CRLF        ;get ready for msg
  432.         CALL    CRLF
  433.         LXI    D,ANSMSG    ;and tell us about it
  434.         MVI    C,PRINT
  435.         CALL    MEX
  436.         LHLD    0101H        ;pointer to start 
  437.         LXI    D,005        ;offset to SP address
  438.         DAD    D        ;for ^C abort
  439.         MOV    A,M        ;get 1st byte
  440.         STA    BOOT+1        ;store it
  441.         INX     H        ;next address
  442.         MOV     A,M        ;get 2nd byte
  443.         STA    BOOT+2        ;store it
  444. WAITCD:        CALL    INPORT        ;to  clear garbage
  445.         CALL    CARRCK        ;check for carrier
  446.         JZ    TSTBAUD        ;yes - go check baud rate...
  447.         MVI    C,CHEKCC    ;no check for ^C
  448.         CALL    MEX
  449.         JNZ    WAITCD        ;no carrier, no ^C so try again
  450. BOOT:        LHLD    0000        ;^C -load CPM return address from
  451.                     ;stack pointer storage 
  452.         SPHL            ;put it in the stack pointer
  453.         RET            ;and go to CPM
  454. TSTBAUD:    CALL    INPORT        ;get byte from modem
  455.         CPI    CR        ;if CR            
  456.         RZ            ;baud rate is good go to MEX
  457.         CPI    LF        ;if LF
  458.         RZ            ;baud rate is good go to MEX
  459.         CPI    'C'-40H     ;if ^C
  460.         RZ            ;baud rate is good go to MEX
  461.         PUSH    H
  462.         PUSH    B
  463.         PUSH    D
  464.         LXI    H,BAUD        ;get baud rate start byte
  465.         MOV    A,M        ;get it out of memory    
  466.         MOV    C,A        ;set it up to operate on it
  467.         INR    C        ;add 1 to it
  468.         MOV    M,C        ;and put it back in start byte
  469.         CALL    PBAUD        ;go set baud rate and MSPEED
  470.         CPI    7        ;have we tried 2400 baud
  471.         JNZ    TSTBAUD        ;no then we're not done
  472.         XRA    A        ;yes then get ready for retry
  473.         STA    BAUD        ;by setting baud back to 110
  474.         POP    D
  475.         POP    B
  476.         POP    H
  477.         JMP    WAITCD        ;we didn't find a good baud rate
  478.                     ;so keep trying until - 1. get a
  479.                     ;good baud rate  2. get a ^C, or
  480.                     ;3. hangup causes carrier loss.
  481. ;
  482. HLPMSG:    DB    CR,LF,'SET command, TRS MOD 4 version '
  483.     db    REV/10+'0'
  484.     DB    '.'
  485.     DB    REV MOD 10 + '0',CR,LF
  486.     DB    CR,LF,'SET BAUD 300 <or> 1200 <or> 2400 <or> 4800 <or> 9600'
  487.     DB    CR,LF,'SET PARITY ON <or> OFF <or> ODD <or> EVEN'
  488.     DB    CR,LF,'SET WORD 5 <or> 6 <or> 7 <or> 8'
  489.     DB    CR,LF,'SET STOP 1 <or> 2'
  490.         DB    CR,LF,'SET ANSWER <on> '
  491.     DB    CR,LF,'$'        
  492. SETEMS:          DB    CR,LF,'SET command error',CR,LF,LF,'$'
  493. TSRCH:        MVI    C,LOOKUP
  494.           JMP    MEX
  495. ;
  496. ILPRT:        MVI    C,ILP        ;MEX print function
  497.         JMP    MEX
  498. ;
  499. CRLF:        MVI    A,CR        ;newline on console
  500.         CALL    TYPE
  501.         MVI    A,LF
  502. TYPE:        PUSH    H        ;save em
  503.         PUSH    D
  504.         PUSH    B
  505.         MOV    E,A
  506.         MVI    C,CONOUT    ;align output char
  507.         CALL    MEX        ;print via mex
  508.         POP    B        ;restore em
  509.         POP    D
  510.         POP    H
  511.         RET        
  512. ;
  513. ; Test for printer ready
  514. ;
  515. PRTSTS:          IN    PRPORT        ;get printer status
  516.           ANI    PRSTAT        ;isolate it
  517.           XRI    030H        ;invert it
  518.         JZ    PRTSTS1        ;return if not ready A=00
  519.           MVI    A,01H        ;get "A" ready to zero  
  520. PRTSTS1:    DCR    A        ;A = 0 not ready
  521.         RET            ;A = FF ready
  522. ; Carrier detect  0=CARRIER
  523. ;
  524. CARRCK:        IN    PORT        ;get carrier bit
  525.         ANI    CTSMSK
  526.         RET
  527. ;    
  528. ; Baud rate set routine 
  529. ;
  530. PBAUD:          PUSH    H        ;save everybody
  531.           PUSH    B
  532.           PUSH    D
  533.         MOV    E,A        ;get speed
  534.         MVI    D,0        ;zero the other half of reg pair
  535.         LXI    H,BAUDTB    ;get baud rate table address
  536.         DAD    D        ;add speed offset
  537.         MOV    A,M        ;get baud rate  
  538.         ORA    A        ;0=not valid baud rate
  539.         JZ    PBEXIT        ;not valid baud rate then exit
  540.         OUT    BAUDRP        ;good baud rate then set it
  541.         MOV    A,E        ;get speed 
  542.         STA    MSPEED        ;set speed
  543.         JMP    PBEXIT1        ;return 
  544. PBEXIT:        STC
  545. PBEXIT1:    POP    B        ;no carrier or incorrect baud rate
  546.           POP    D
  547.           POP       H
  548.           RET
  549. ;
  550. BAUDTB:        DB    0,055H,0,0,0        ;110,300,450,610,710
  551.         DB    077H,0AAH,0CCH,0EEH,0    ;1200,2400,4800,9600,19200
  552. ;
  553. STTBL:        DB    '1'+80H        ;stop bit tabe
  554.         DW    STONE        ;set one bit
  555.         DB    '2'+80H
  556.         DW    STTWO        ;set two bits
  557.         DB    0
  558. ;
  559. PARTBL:        DB    'O','N'+80H    ;parity table
  560.         DW    STON        ;enable parity
  561.         DB    'OF','F'+80H
  562.         DW    STOFF        ;disable parity
  563.         DB    'EVE','N'+80H
  564.         DW    STEVE        ;even parity
  565.         DB    'OD','D'+80H
  566.         DW    STODD        ;odd parity    
  567.         DB    0
  568. ;
  569. WLTBL:        DB    '5'+80H        ;word length table
  570.         DW    STFIVE        ;5 bit length
  571.         DB    '6'+80H
  572.         DW    STSIX        ;6 bit length
  573.         DB    '7'+80H
  574.         DW    STSEV        ;7 bit length
  575.         DB    '8'+80H
  576.         DW    STATE        ;8 bit length
  577.         DB    0
  578. ;
  579. STFIVE:        LDA    CURURT        ;get current port info
  580.         ANI    09FH        ;change to 5 bits
  581.         STA    CURURT        ;put back new port info
  582.         MVI    A,'5'        ;set 5 bit flag
  583. STFIVE1:    STA    WLTEL    
  584.         CALL    SETURT        ;Tell UART of change
  585.         CALL    CARRCK        ;carrier present
  586.         RZ            ;yep then continue
  587.         CALL    TYPE        ;position cursor
  588.         CALL    WLSHOW        ;nope show word length
  589.         RET
  590. STSIX:        LDA    CURURT        ;get current port info 
  591.         ORI    U$WRD6        ;set six bits    
  592.         ANI    0DFH
  593.         STA    CURURT        ;put new 
  594.         MVI    A,'6'        ;set six bit flag
  595.         JMP    STFIVE1
  596. STSEV:        LDA    CURURT        ;get current port info
  597.         ORI    U$WRD7        ;set seven bits
  598.         ANI    0BFH
  599.         STA    CURURT        ;put back new port info
  600.         MVI    A,'7'        ;set 7 bit flag            
  601.         JMP    STFIVE1
  602. STATE:        LDA    CURURT        ;get current port info
  603.         ORI    U$WRD8        ;set eight bit
  604.         STA    CURURT        ;put back new port info
  605.         MVI    A,'8'        ;set 8 bit flag
  606.         JMP    STFIVE1
  607. ;
  608. STON:        LDA    CURURT        ;get current port info
  609.         ANI    0F7H        ;set parity on
  610.               STA    CURURT        ;put back new port info
  611.         MVI    A,YES
  612. STON1:        STA    PARTEL        ;set parity on flag
  613.         CALL    SETURT        ;Tell UART of change
  614.         CALL    CARRCK        ;carrier present
  615.         RZ            ;yep then continue
  616.         CALL    TYPE        ;position cursor
  617.         CALL    PARSHOW        ;nope then show parity info 
  618.         RET
  619. STOFF:        LDA    CURURT        ;get curent port info
  620.         ORI    008H        ;set parity off
  621.         STA    CURURT        ;put back new port info
  622.         MVI    A,NO        ;set no parity flag
  623.         JMP    STON1    
  624. STODD:        LDA    CURURT        ;get current port info
  625.         ANI    07FH        ;set parity odd
  626.         STA    CURURT        ;put back new port info
  627.         MVI    A,YES        ;set parity odd flag
  628. STODD1:        STA    PARTEL1
  629.         CALL    SETURT        ;Tell UART of change
  630.         CALL    CARRCK        ;carrier present
  631.         RZ            ;yep then return
  632.         CALL    TYPE        ;position cursor
  633.         CALL    PARSHOW        ;nope show parity info
  634.         RET
  635. STEVE:        LDA    CURURT        ;get current port info
  636.         ORI    080H        ;set even parity
  637.         STA    CURURT        ;put back new port info
  638.         MVI    A,NO        ;set even parity flag
  639.         JMP    STODD1
  640. STONE:        LDA    CURURT        ;get current port info
  641.         ANI    0EFH        ;set one stop bit 
  642.         STA    CURURT        ;put back new port info
  643.         MVI    A,YES        ;set one stop bit flag
  644. STONE1:        STA    STTEL        
  645.         CALL    SETURT        ;Tell UART of change
  646.         CALL    CARRCK        ;carrier present
  647.         RZ            ;yep then continue
  648.         CALL    STSHOW        ;nope show stop bit info 
  649.         RET
  650. STTWO:        LDA    CURURT        ;get current port info
  651.         ORI    010H        ;set two stop bits
  652.         STA    CURURT        ;put back new port info
  653.         MVI    A,NO        ;set two stop bit flag
  654.         JMP    STONE1            
  655. ;
  656. PARSHOW:    LXI    D,PARMSG    ;get parity message
  657.         MVI    C,PRINT        ;print it
  658.         CALL    MEX
  659.         LXI    D,PONMSG    ;get set for parity on
  660.         MVI    C,PRINT
  661.         LDA    PARTEL        ;get flag
  662.         CPI    YES         ;is it on
  663.         JZ    PARSHOW1    ;yes then say so
  664.         LXI    D,POFMSG    ;no then get parity off message
  665.         MVI    C,PRINT        ;print it
  666.         CALL    MEX
  667.         RET
  668. PARSHOW1:    CALL    MEX
  669.         LXI    D,ODDMSG    ;get parity odd message
  670.         MVI    C,PRINT
  671.         LDA    PARTEL1        ;get odd parity flag
  672.         CPI    YES        ;is it odd
  673.         JNZ      PARSHOW2    ;nope get even message
  674.         CALL    MEX        ;yes then say so 
  675.         RET
  676. PARSHOW2:    LXI    D,EVEMSG    ;get even parity message
  677.         MVI    C,PRINT        
  678.         CALL    MEX        ;print it
  679.         RET
  680. ;
  681. WLSHOW:        LXI    D,WLMSG        ;get word length message
  682.         MVI    C,PRINT
  683.         CALL    MEX        ;print it
  684.         LXI    D,FIVEMSG    ;load five bit message
  685.         MVI    C,PRINT    
  686.         LDA    WLTEL        ;get word length flag 
  687.         CPI    '5'        ;is it five
  688.         JNZ     SIX        ;nope try six
  689.         CALL    MEX        ;yes then show it
  690.         RET
  691. SIX:        LXI    D,SIXMSG    ;load six bit message
  692.         MVI    C,PRINT
  693.         CPI    '6'        ;is it six
  694.         JNZ    SEV        ;nope try seven
  695.         CALL    MEX        ;yep then show it
  696.         RET
  697. SEV:        LXI    D,SEVMSG    ;load seven bit message
  698.         MVI    C,PRINT
  699.         CPI    '7'        ;is it seven
  700.         JNZ    ATE        ;nope try eight
  701.         CALL    MEX        ;yep then show it
  702.         RET
  703. ATE:        LXI    D,ATEMSG    ;load eight bit message
  704.         MVI    C,PRINT
  705.         CALL    MEX        ;print it
  706.         RET
  707. ;
  708. STSHOW:        LXI    D,STOPMSG    ;get stop bit message
  709.         MVI    C,PRINT        ;print it
  710.         CALL    MEX
  711.         LXI    D,STOPMSG1    ;get stop bit 1 message
  712.         MVI    C,PRINT
  713.         LDA    STTEL        ;is it 1 bit
  714.         CPI    YES
  715.         JNZ    STSHOW1        ;nope try two
  716.         CALL    MEX        ;yep then show it 
  717.         RET
  718. STSHOW1:    LXI    D,STOPMSG2    ;get stop bit 2 message
  719.         MVI    C,PRINT
  720.         CALL    MEX        ;print it
  721.         RET
  722. ;
  723. ; Message area
  724. ;
  725. BAUD:        DB    DFBAUD        ;2400 baud
  726. CURURT:        DB    DEFCTB        ;Current UART configuration bits
  727. PARTEL:        DB    NO        ;yes=parity, no=no parity
  728. PARTEL1:    DB    NO        ;yes=odd parity, no=even
  729. WLTEL:        DB    '8'        ;5=5 bits,6=6 bits, etc.
  730. STTEL:        DB    YES        ;yes=1 stop, no=2 stop 
  731. STOPMSG:    DB    'Number of stop bits is $'
  732. STOPMSG1:    DB    '1$'
  733. STOPMSG2:    DB    '2$'        
  734. WLMSG:        DB    'Word length is $'
  735. FIVEMSG:    DB    '5 bits$'
  736. SIXMSG:        DB    '6 bits$'
  737. SEVMSG:        DB    '7 bits$'
  738. ATEMSG:        DB    '8 bits$'      
  739. PARMSG:        DB    'Parity is: $'
  740. PONMSG:        DB    'on and $'
  741. POFMSG:        DB    'off$'
  742. ODDMSG:        DB    'odd$'
  743. EVEMSG:        DB    'even$'
  744. CLSMSG:          DB    CR,LF,1AH,'$'
  745. EOSMSG:          DB    CR,LF,19H,'$'
  746. SOMESG:          DB    'TRS Mod 4 CP/M 2.2 overlay V'
  747.           DB    REV/10+'0'
  748.           DB    '.'
  749.           DB    REV MOD 10+'0','$'
  750. NOMESG:        DB    ONV,'no $'
  751. CARMSG:        DB    ONV,'carrier present',INV,CR,LF,'$'
  752. ANSON:        DB    'ATZS0=',RING,CR,0   ;turn on auto answer
  753. ANSMSG:        DB    'Auto answer mode now turned on. '
  754.         DB    '[Use ^C to return to CPM]'
  755.         DB    CR,LF,'$'
  756. ;
  757. ;****************************************************************************
  758. ;--THIS ROUTINE IS USED IF NOMXOSM = YES, AND THE MXO-SMxx.ASM FILE IS
  759. ;--APPENDED TO THIS ONE.
  760. ;****************************************************************************
  761. ;
  762.         IF    NOMXOSM
  763. SMSEND:        MVI    C,SNDRDY    ;Routine extracted from MXO-SMxx.ASM
  764.         CALL    MEX        ;to be used only if MXO-RS.ASM and
  765.         JNZ    SMSEND        ;MXO-SMxx.ASM are assembled and loaded
  766.         MOV    A,M        ;as two seperate files.
  767.         INX    H
  768.         ORA    A
  769.         RZ
  770.         MOV    B,A
  771.         MVI    C,SNDCHR
  772.         CALL    MEX
  773.         JMP    SMSEND
  774.         ENDIF        
  775. ;
  776. ;-----------------------------------------------------------------------------
  777. ; NOTE:  MUST TERMINATE PRIOR TO 0B00H (with Smartmodem or Anchor)
  778. ;-----------------------------------------------------------------------------
  779. ; End of TRS-80 MOD IV  MEX modem overlay
  780. ;
  781. ;******************************************************************************
  782.      END    ;Comment out this line to use with MXMSMxx.ASM and NOMXOSM=NO
  783. ;******************************************************************************
  784.  line to use with MXMSMxx.ASM and NOMXOSM=NO
  785. ;*****************************************************