home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols200 / vol273 / i2mda-2.asm < prev    next >
Encoding:
Assembly Source File  |  1994-07-13  |  19.8 KB  |  820 lines

  1. ; I2MDA-2.ASM - Morrow Micro-Decision overlay file for IMP - 09/23/85
  2. ; ============================================================================
  3. ; Version for ALL Micro-Decisions, including hard disk models, ROM revision
  4. ; 1.x machines (no parallel port), and ROM revision 2.x and 3.x machines
  5. ; (with parallel port).
  6. ; ----------------------------------------------------------------------------
  7. ; If you are using this overlay for the MD-HD computer (MD-5, -11, etc.),
  8. ; you have two additional options in the SET command: AUX and P/M.
  9. ; Using SET AUX selects the Auxilliary port as your modem port, and
  10. ; SET P/M selects the Printer/Modem port.  Select either the MDHDA or
  11. ; the MDHDP equate below as the DEFAULT modem port.  You can always use
  12. ; the SET command later to swap ports.
  13. ;                                             - Paul Bartholomew
  14. ; ----------------------------------------------------------------------------
  15. ;
  16. ;
  17. ; You will want to look this file over carefully. There are a number of
  18. ; options that you can use to configure the program to suit your taste.
  19. ; This file adapts all of the MD series computers. Be sure and select
  20. ; which model you have below.
  21. ;
  22. ; Edit this file for your preferences then follow the "TO USE:" example
  23. ; shown below.
  24. ;
  25. ; Many terminals will clear the screen with a CTL-Z.  If yours does, put
  26. ; a 1AH at CLEAR: (010AH).  Many terminals use two characters, the first
  27. ; normally an ESC.  For example, ESC *.  In this case put '*' at CLEAR:
  28. ; (The ESC will automatically be typed with no CTL-character present.)
  29. ; If you don't know what your terminal uses, put a 0 at CLEAR: and IMP
  30. ; will scroll up 24 blank lines to clear the CRT for things like MENU,
  31. ; looking at the function key table, typing CTL-Z in command mode, etc.
  32. ;
  33. ; Use the "SET" command to change the baudrate when desired.  The value
  34. ; at MSPEED controls the baudrate when the program is first called up.
  35. ;
  36. ;    TO USE: First edit this file filling in answers for your own
  37. ;        equipment.  Then assemble with ASM.COM or equivalent
  38. ;        assembler.  Then use MLOAD to merge into the main file:
  39. ;
  40. ;        MLOAD IMP.COM=IMP.COM,I2MDA-x.HEX
  41. ;
  42. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  43. ;
  44. ; 09/24/85 - Fixed bug with MD-HD overlay trashing the BC registers in
  45. ;            the I/O routines.  There are now only 3 or 4 bytes left
  46. ;            in the MD-HD overlay before it goes past the 0400h limit.
  47. ;                                               - Paul Bartholomew
  48. ; 09/23/85 - Written to work with IMP        - Paul Bartholomew
  49. ;
  50. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  51. ;
  52. ;
  53. YES    EQU    0FFH
  54. NO    EQU    0
  55. ;
  56. ;
  57. ; Set ONE AND ONLY ONE of the following to YES, all the rest to NO:
  58. ;
  59. MD3R1    EQU    NO     ; Set to YES for MD-2/3 with Revision 1.x ROM
  60. MD3R2    EQU    NO     ; Set to YES for MD-2/3 with Revision 2.x or 3.x ROM
  61. MDHDA    EQU    YES    ; Set to YES for MD-HD using Auxilliary port
  62. MDHDP    EQU    NO     ; Set to YES for MD-HD using Printer/Modem port
  63. SSPEED    EQU    5    ; Initial baud rate, 0=110 1=300 2=450 3=600 4=710
  64.             ; 5=1200 6=2400 7=4800 8=9600 9=19200
  65. ;
  66. ; EQUates for MD-2/3 all ROM's
  67. ;
  68.      IF    (MD3R1 OR MD3R2)
  69. MDDATP    EQU    0FEH    ; Printer/Modem DATA port
  70. MDCTL1    EQU    0FFH    ; Printer/Modem STATUS port
  71. MDRCV    EQU    02H    ; Modem receive ready
  72. MDSND    EQU    01H    ; Modem send ready bit
  73. MDTXE    EQU    05H    ; Modem send buffer empty, holding buffer empty
  74.      ENDIF
  75.  
  76. ;
  77. ;CTC EQUates for MD-2/3 ROM 2.x and 3.x
  78. ;
  79.      IF    MD3R2
  80. BPORT    EQU    0F2H
  81. CPORT    EQU    0F3H
  82. CTCSEL    EQU    0BEH
  83.      ENDIF
  84.  
  85. ;
  86. ;EQUates for MD-HD using Auxilliary port
  87. ;
  88.      IF    MDHDA
  89. PORT    EQU    70H    ; Auxilliary BASE port
  90. BRPORT    EQU    50H    ; Baud rate port
  91. BMODE    EQU    3EH    ; Mode
  92.      ENDIF
  93.  
  94. ;
  95. ;EQUates for MD-HD using Printer/Modem port
  96. ;
  97.      IF    MDHDP
  98. PORT    EQU    62H    ; Printer/Modem BASE port
  99. BRPORT    EQU    51H    ; Baud rate port
  100. BMODE    EQU    7EH    ; Mode
  101.      ENDIF
  102. ;
  103. ;EQUates for MD-HD
  104. ;
  105.      IF    (MDHDA OR MDHDP)
  106. MDCTL1    EQU    PORT+1    ; Modem control port
  107. MDDATP    EQU    PORT    ; Modem data port
  108. MOPORT    EQU    53H    ; Mode port
  109. MDRCV    EQU    01H    ; Modem receive ready
  110. MDSND    EQU    04H    ; Modem send ready bit
  111. MDTXE    EQU    01H    ; Modem send buffer empty, holding buffer empty
  112.      ENDIF
  113. ;
  114. ;-----------------------------------------------------------------------
  115. ;
  116. ESC    EQU    '['-40H    ; ^[ = Escape
  117. BELL    EQU    'G'-40H    ; ^G = Bell character
  118. LF    EQU    'J'-40H    ; ^J = Linefeed
  119. NEXTRY    EQU    'K'-40H    ; ^K = Try next phone number, abort this try
  120. CR    EQU    'M'-40H    ; ^M = Carriage return
  121. CLEARSC    EQU    'Z'-40H    ; ^Z = Clears screen, command mode only
  122. EOFCHAR    EQU    'Z'-40H    ; ^Z = End of file
  123. ;
  124. ;
  125. ;-----------------------------------------------------------------------
  126. ;
  127. ;
  128.     ORG    0100H
  129. ;
  130. ;
  131.     DS    3    ; Skip the data area below
  132. ;
  133. ;
  134. ; These routines and equates are at the beginning of the program so
  135. ; they can be patched by a monitor or overlay file without re-assembling
  136. ; the program.
  137. ;
  138. MSPEED:     DB    SSPEED    ; 0=110 1=300 2=450 3=600 4=710 5=1200        103H
  139.             ; 6=2400 7=4800 8=9600 9=19200 default
  140. HS2400:     DB    NO    ; Yes=2400 bps highest speed            104H
  141. HS1200:     DB    YES    ; Yes=1200 bps highest speed            105H
  142. RACAL:     DB    NO    ; Yes=Racal-Vadic 1200V or 2400V or 2400PA    106H
  143. PROMODM: DB    NO     ; Yes=Prometheus ProModem 1200 bps        107H
  144. RESVD1:     DB    NO    ; Reserved for special modems            108H
  145. RESVD2:     DB    NO    ; Reserved for special modems            109H
  146. ;
  147. ;
  148. CLEAR:     DB    '*'    ; Clear screen character (ESC not needed)    10AH
  149. CLOCK:     DB    40    ; Clock speed in MHz x10, 25.5 MHz max.     10BH
  150.             ; 20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  151. BYTDLY:     DB    2    ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms        10CH
  152.             ;   default time to send character in ter-
  153.             ;   minal mode file transfer for slow BBS
  154. CRDLY:     DB    2    ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms    10DH
  155.             ;   default time for extra wait after CRLF
  156.             ;   in terminal mode file transfer
  157. NOFCOL:     DB    5    ; Number of directory columns shown        10EH
  158. TCHPUL:     DB    'T'    ; T=tone, P=Pulse (Hayes 2400 modems)        10FH
  159. ;.....
  160. ;
  161. ;
  162. ADDLFD:     DB    NO    ; Yes=add LF after CR to send file in terminal    110H
  163.             ;   mode (normally added by remote echo)
  164. CONVRUB: DB    YES    ; Yes=convert rub to backspace            111H
  165. CRCDFLT: DB    YES    ; Yes=default to CRC checking            112H
  166. IGNRCTL: DB    NO    ; Yes=CTL-chars above ^M not displayed        113H
  167. ;.....
  168. ;
  169. ;
  170. EXTCHR:     DB    '['-40H    ; ESC = preceeds local control character    114H
  171. EXITCHR: DB    'E'    ; Exit character                115H
  172. FILESND: DB    'F'    ; Send file when in terminal mode        116H
  173. NOCONCT: DB    'N'    ; Disconnect from phone line            117H
  174. LOGCHR:     DB    'L'    ; Send logon                    118H
  175. LSTCHR:     DB    'P'    ; Toggle printer                119H
  176. UNSAVCH: DB    'R'    ; Close input text buffer            11AH
  177. SAVECHR: DB    'Y'    ; Open input text buffer            11BH
  178. CLEARS:     DB    'Z'    ; Clears screen, terminal mode            11CH
  179. SPARE1:     DB    0    ; For future development            11DH
  180. SPARE2:     DB    0    ; For future development            11EH
  181. ;.....
  182. ;
  183. ;
  184. ; Handles in/out ports for data and status
  185. ;
  186. I$MDCTL1:
  187.       JMP    IMDC        ;                    11FH
  188.       DB    0,0,0,0,0,0,0    ; Spares if needed            122H
  189. ;
  190. I$MDTXE:
  191.       JMP    IMDT        ;                    129H
  192.       DB    0,0,0,0,0,0,0    ;                    12CH
  193. ;
  194. I$MDDATP:
  195.       JMP    IMDD        ;                    133H
  196.       DB    0,0,0,0,0,0,0    ;                    136H
  197. ;
  198. O$MDDATP:
  199.       JMP    OMDD        ;                    13DH
  200.       DB    0,0,0,0,0,0,0    ;                    140H
  201. ;.....
  202. ;
  203. ;
  204. A$MDRCV:  ANI    MDRCV        ;                    147H
  205.       RET            ;                    149H
  206. ;
  207. C$MDRCV:  CPI    MDRCV        ;                    14AH
  208.       RET            ;                    14CH
  209. ;
  210. A$MDSND:  ANI    MDSND        ;                    14DH
  211.       RET            ;                    14FH
  212. ;
  213. C$MDSND:  CPI    MDSND        ;                    150H
  214.       RET            ;                    152H
  215. ;
  216. A$MDTXE:  ANI    MDTXE        ;                    153H
  217.       RET            ;                    155H
  218. ;
  219. C$MDTXE:  CPI    MDTXE        ;                    156H
  220.       RET            ;                    158H
  221. ;.....
  222. ;
  223. ;
  224. ; Special exit vector, used by some computers to reset interrupt vectors
  225. ;
  226. J$EXITVEC:RET            ;                    159H
  227.       DB    0,0        ;                    15AH
  228. ;.....
  229. ;
  230. ;
  231. ; Jump vectors needed by each overlay
  232. ;
  233. J$GOODBYE:JMP    GOODBYE        ; Disconnects modem by dropping DTR    15CH
  234. J$INITMOD:JMP    INITMOD        ; Initializes modem, autosets baudrate    15FH
  235. J$STUPR:  JMP    STUPR        ; SET routine to change baudrate    162H
  236. J$SYSVR:  JMP    SYSVR        ; Signon message            165H
  237. ;.....
  238. ;
  239. ;
  240. ; "AT" command strings, can be replaced in individual overlay if needed
  241. ;
  242. J$STRNGA: DS    3        ; 1200 bps "AT" string            168H
  243. J$STRNG1: DS    3        ; 2400 bps "AT" string            16B:IMP
  244. ;
  245. ;
  246. ; Next fourteen lines should not be changed by user overlay as these go
  247. ; to specific locations in the main program, not in the overlay.
  248. ;
  249. ;
  250. J$CMDSPL: DS    3        ; Allows entry of baudrate on CMD line    16EH
  251. J$CRLF:      DS    3        ; Turns up one new line on display    171H
  252. J$DIAL:      DS    3        ; Start of dialing routine        174H
  253. J$DSCONT: DS    3        ; Terminates modem use            177H
  254. J$GOLST:  DS    3        ; Printer routine, needed by Apple //e    17AH
  255. J$ILPRT:  DS    3        ; Prints an inline string, 0 to end    17DH
  256. J$INBUF:  DS    3        ; Stores a keybd string for comparison    180H
  257. J$INLNCP: DS    3        ; Inline "compare strings" routine    183H
  258. J$INMDM:  DS    3        ; Max .1 sec wait for modem character    186H
  259. J$RCVRSP: DS    3        ; For 3801 I/O use (TV-803)        189H
  260. J$SNDCHR: DS    3        ; Sends a character to the modem    18CH
  261. J$SNDSTR: DS    3        ; Sends a string to the modem, $ to end 18FH
  262. J$TIMER:  DS    3        ; .1 second timer (amount in 'B' reg.)    192H
  263. J$NEW1:      DB    0,0,0        ; For future needs            195H
  264. J$NEW2:      DB    0,0,0        ; For future needs            198H
  265. ;.....
  266. ;
  267. ;
  268. ; For 2400 bps auto-stepdown units
  269. ;
  270. MANUAL:      DB    0        ; For manual selection flag        19BH
  271. J$300:      JMP    OK300        ; Sets baudrate to 300 baud        19CH
  272. J$1200:      JMP    OK1200        ; Sets baudrate to 1200 bps        19FH
  273. J$2400:      JMP    OK2400        ; Sets baudrate to 2400 bps        1A2H
  274. ;.....
  275. ;
  276. ;
  277. LOGPTR:      DW    LOGON        ; Pointer to display LOGON message    1A5H
  278. ;
  279. SYSVR:      CALL    J$ILPRT        ; Display the following line        1A7H
  280.       DB    'Version for '    ;                    1AAH
  281.  
  282.        IF    MD3R1
  283.       DB    'Morrow MD-2/3 with Revision 1.x ROM'
  284.        ENDIF
  285.  
  286.        IF    MD3R2
  287.       DB    'Morrow MD-2/3 with Revision 2.x or 3.x ROM'
  288.        ENDIF
  289.  
  290.        IF    MDHDA
  291.       DB    'Morrow MD-HD using Auxilliary Port'
  292.        ENDIF
  293.  
  294.        IF    MDHDP
  295.       DB    'Morrow MD-HD using Printer/Modem Port'
  296.        ENDIF
  297.  
  298.       DB    CR,LF,0
  299.       RET
  300. ;.....
  301. ;
  302. ;
  303. ;-----------------------------------------------------------------------
  304. ;
  305. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  306. ;     end of your last routine should terminate by 0400H (601 bytes
  307. ;     available after start of SYSVER).
  308. ;
  309. ;-----------------------------------------------------------------------
  310. ;
  311. ; You can put in a message at this location which can be called up with
  312. ; (special character-L).  You can put in several lines.  End with a 0.
  313. ;
  314. LOGON:    DB    'This is a Morrow Micro Decision',CR,LF,0
  315. ;
  316. ;-----------------------------------------------------------------------
  317.  
  318. ;=======================================================================
  319. ;
  320. ; Modem I/O for MD-2/3 all ROM's:
  321. ;
  322.      IF    (MD3R1 OR MD3R2)
  323. ;
  324. ;Input STATUS to A
  325. ;
  326. IMDC:
  327.     IN    MDCTL1
  328.     RET
  329. ;
  330. ;Check for transmit ready
  331. ;
  332. IMDT:
  333.     IN    MDCTL1
  334.     RET
  335. ;
  336. ;Input byte from DATA port to A
  337. ;
  338. IMDD:
  339.     MVI    A,37H
  340.     OUT    MDCTL1
  341.     IN    MDDATP
  342.     RET
  343. ;
  344. ;Output byte in A to DATA port
  345. ;
  346. OMDD:
  347.     OUT    MDDATP
  348.     RET
  349.      ENDIF        ;(MD3R1 OR MD3R2)
  350.  
  351. ;=======================================================================
  352. ;
  353. ; Modem I/O for MD-HD using either port:
  354. ;
  355.      IF    (MDHDA OR MDHDP)
  356. ;
  357. ;BASE PORT - Changed by SET
  358. ;
  359. ;DON'T CHANGE THE ORDER OF THE FOLLOWING BYTES!
  360. ;
  361. BSPRT:    DB    PORT
  362. BRPRT:    DB    BRPORT
  363. BMD:    DB    BMODE
  364. ;
  365. ;Input STATUS to A
  366. ;
  367. IMDC:
  368.     PUSH    B
  369.     LDA    BSPRT
  370.     MOV    C,A
  371.     INR    C
  372.     MVI    A,10H        ; Register 0, reset interrupts
  373. ;    out    (c),a        ; Z80 instruction
  374.     dw    79edh        ; Z80 opcodes
  375. ;    in    a,(c)        ; Z80 instruction
  376.     dw    78edh        ; Z80 opcodes
  377.     POP    B
  378.     RET            ; IN modem control port
  379. ;
  380. ;Check for transmit ready
  381. ;
  382. IMDT:
  383.     PUSH    B
  384.     LDA    BSPRT
  385.     MOV    C,A
  386.     INR    C
  387.     MVI    A,11H        ; Read register 1, for "all sent"
  388. ;    out    (c),a        ; Z80 instruction
  389.     dw    79edh        ; Z80 opcodes
  390. ;    in    a,(c)        ; Z80 instruction
  391.     dw    78edh        ; Z80 opcodes
  392.     POP    B
  393.     RET
  394. ;
  395. ;Input byte from DATA port to A
  396. ;
  397. IMDD:
  398.     PUSH    B
  399.     LDA    BSPRT
  400.     MOV    C,A
  401. ;    in    a,(c)        ; Z80 instruction
  402.     dw    78edh        ; Z80 opcodes
  403.     POP    B
  404.     RET
  405. ;
  406. ;Output byte in A to DATA port
  407. ;
  408. OMDD:
  409.     PUSH    B
  410.     PUSH    PSW
  411.     LDA    BSPRT
  412.     MOV    C,A
  413.     POP    PSW
  414. ;    out    (c),a        ; Z80 instruction
  415.     dw    79edh        ; Z80 opcodes
  416.     POP    B
  417.     RET
  418.      ENDIF        ;(MDHDA OR MDHDP)
  419.  
  420. ;=============================================================================
  421. ;
  422. ; MD-2/3 all ROM's routine to set DTR low for 1 second to disconnect the phone
  423. ;
  424.        IF    (MD3R1 OR MD3R2)
  425. GOODBYE:
  426.     MVI    B,'S'-40H    ; X-off to stop host if needed
  427.     CALL    J$SNDCHR
  428.     MVI    B,1        ; Wait a moment to let it react
  429.     CALL    J$TIMER
  430.     MVI    A,15H        ;SEND BREAK, TURN OFF DTR
  431. GOODBYE1:
  432.     OUT    MDCTL1        ;SEND TO STATUS PORT
  433.     MVI    B,3        ;WAIT 300 MS.
  434.     CALL    J$TIMER
  435.     MVI    A,07H        ;NORMAL SEND/RECEIVE WITH DTR
  436.     OUT    MDCTL1        ;SEND TO STATUS PORT
  437.     RET
  438.      ENDIF        ;MD3R1
  439.  
  440. ;=============================================================================
  441. ;
  442. ; MD-HD routine to set DTR low for 1 second to disconnect the phone
  443. ;
  444.     IF    (MDHDA OR MDHDP)
  445. GOODBYE:
  446.     PUSH    B
  447.     MVI    B,'S'-40H    ; X-off to stop host if needed
  448.     CALL    J$SNDCHR
  449.     MVI    B,1        ; Wait a moment to let it react
  450.     CALL    J$TIMER
  451.  
  452.     LDA    BSPRT
  453.     MOV    C,A
  454.     INR    C
  455.     MVI    A,5
  456. ;    out    (c),a        ; Send to the status port
  457.     dw    79edh
  458.     MVI    A,68H        ; Turn off DTR
  459. ;    out    (c),a
  460.     dw    79edh
  461.     MVI    B,3        ; Wait for 300 ms
  462.     PUSH    B
  463.     CALL    J$TIMER
  464.     POP    B
  465.     MVI    A,5
  466. ;    out    (c),a
  467.     dw    79edh
  468.     MVI    A,0E8H        ; Restore normal, 8 bits, DTR on, etc.
  469. ;    out    (c),a
  470.     dw    79edh
  471.     POP    B
  472.     RET
  473.      ENDIF            ;(MDHDA OR MDHDP)
  474.  
  475. ;=============================================================================
  476. ;
  477. ; MD-2/3 ROM 1.x initialization
  478. ;
  479.        IF    MD3R1
  480. INITMOD:
  481.     MVI    A,087H        ;INSURE OUT OF MODE
  482.     OUT    MDCTL1        ;MODEM STATUS PORT
  483.     OUT    MDCTL1        ;SLIGHT EXTRA DELAY
  484.     MVI    A,40H        ;INITIALIZE USART
  485.     OUT    MDCTL1        ;MODEM STATUS PORT
  486. ;
  487. INITMOD1:
  488.     MVI    A,17H        ;DTR, RCV, XMT, ERROR RESET
  489.     OUT    MDCTL1        ;MODEM STATUS PORT
  490.     IN    MDDATP        ;CLEAR DATA PORT
  491.     LDA    MSPEED        ; Get the selected value
  492.     CPI    9+1
  493.     JNC    STUPR1        ; If invalid, ask for baud, else
  494.     JMP    GETBAUD        ; set to default
  495.      ENDIF        ;MD3R1
  496.  
  497. ;=============================================================================
  498. ;
  499. ; MD-2/3 ROM 2.x and 3.x initialization
  500. ;
  501.        IF    MD3R2
  502. INITMOD:                ; MAKES SURE WE ARE OK ON THE 2ND
  503.     MVI    A,087H            ; SERIAL PORT
  504.     OUT    MDCTL1
  505.     MVI    A,40H
  506.     OUT     MDCTL1
  507.     MVI    A,4EH
  508.     OUT    MDCTL1  
  509.     MVI    A,17H
  510.     OUT     MDCTL1
  511. ;
  512. INITMOD1:                ; SETS DEFAULT BAUD RATE TO 1200 ON CTC
  513.     LDA    MSPEED        ; Get the selected value
  514.     CPI    9+1
  515.     JNC    STUPR1        ; If invalid, ask for baud, else
  516.     JMP    GETBAUD        ; set to default
  517.      ENDIF        ;MD3R1
  518.  
  519. ;=============================================================================
  520. ;
  521. ; Morrow MD-HD initialization
  522. ;
  523.      IF    (MDHDA OR MDHDP)
  524. INITMOD:
  525.     PUSH    B
  526.     LDA    BSPRT
  527.     MOV    C,A
  528.     INR    C
  529.     MVI    A,0        ; Select register
  530. ;    out    (c),a
  531.     dw    79edh
  532.     MVI    A,18H        ; Throw out of mode
  533. ;    out    (c),a
  534.     dw    79edh
  535.     MVI    A,04H        ; Select register
  536. ;    out    (c),a
  537.     dw    79edh
  538.     MVI    A,44H        ; 16x, 1 stop, parity off (44=1, 4C=2)
  539. ;    out    (c),a
  540.     dw    79edh        ; (4CH for 16x, 2 stop, parity off)
  541.     MVI    A,03H        ; Select register
  542. ;    out    (c),a
  543.     dw    79edh
  544.     MVI    A,0C1H        ; Enable receive
  545. ;    out    (c),a
  546.     dw    79edh
  547.     MVI    A,05H        ; Select register
  548. ;    out    (c),a
  549.     dw    79edh
  550.     MVI    A,0E8H        ; Enable send, 'DTR', 'RTS'
  551. ;    out    (c),a
  552.     dw    79edh
  553. ;
  554.     POP    B
  555.     LDA    MSPEED        ; Get the selected value
  556.     CPI    9+1
  557.     JNC    STUPR1        ; If invalid, ask for baud, else
  558.     JMP    GETBAUD        ; set to default
  559.      ENDIF            ;(MDHDA OR MDHDP)
  560. ;.....
  561. ;
  562. ;
  563. ; Setup routine to allow changing modem speed with the SET command.
  564. ;
  565. STUPR:    CALL    J$CMDSPL    ; Gives us CMDBUF+6
  566.     JNC    STUPR2
  567. ;
  568. STUPR1:    CALL    J$ILPRT
  569.     DB    'Input Baud Rate '
  570.  
  571.      IF    MD3R1
  572.     DB    '(300,1200): ',0
  573.      ENDIF
  574.  
  575.      IF    MD3R2
  576.     DB    '(110,300,450,600,1200,2400,4800,9600): ',0
  577.      ENDIF
  578.  
  579.      IF    (MDHDA OR MDHDP)
  580.     DB    '(110,300,600,1200,2400,4800,9600,19200,P/M,AUX): ',0
  581.      ENDIF
  582.  
  583.     LXI    D,BAUDBUF    ; Point to new input buffer
  584.     CALL    J$INBUF
  585.     CALL    J$CRLF
  586.     LXI    D,BAUDBUF+2
  587. ;
  588. STUPR2:
  589.      IF    (NOT MD3R1)
  590.     CALL    J$INLNCP    ; Compare BAUDBUF+2 with chars. below
  591.     DB    '110',0
  592.     JNC    OK110        ; Go if match
  593.      ENDIF
  594. ;
  595.     CALL    J$INLNCP
  596.     DB    '300',0
  597.     JNC    OK300
  598. ;
  599.      IF    MD3R2
  600.     CALL    J$INLNCP
  601.     DB    '450',0
  602.     JNC    OK450
  603.      ENDIF
  604. ;
  605.      IF    (NOT MD3R1)
  606.     CALL    J$INLNCP
  607.     DB    '600',0
  608.     JNC    OK600
  609.      ENDIF
  610. ;
  611.     CALL    J$INLNCP
  612.     DB    '1200',0
  613.     JNC    OK1200
  614. ;
  615.      IF    (NOT MD3R1)
  616.     CALL    J$INLNCP
  617.     DB    '2400',0
  618.     JNC    OK2400
  619. ;
  620.     CALL    J$INLNCP
  621.     DB    '4800',0
  622.     JNC    OK4800
  623. ;
  624.     CALL    J$INLNCP
  625.     DB    '9600',0
  626.     JNC    OK9600
  627.      ENDIF
  628. ;
  629.      IF    (MDHDA OR MDHDP)
  630.     CALL    J$INLNCP
  631.     DB    '19200',0
  632.     JNC    OK19200
  633.  
  634.     CALL    J$INLNCP
  635.     DB    'P/M',0
  636.     JNC    OKPM
  637.  
  638.     CALL    J$INLNCP
  639.     DB    'AUX',0
  640.     JNC    OKAUX
  641.      ENDIF
  642. ;
  643.     CALL    J$ILPRT        ; All matches failed, tell operator
  644.     DB    '++ Incorrect entry ++',CR,LF,BELL,CR,LF,0
  645.     JMP    STUPR1        ; Try again
  646. ;
  647.  
  648. ;=============================================================================
  649. ;
  650. ;Baud rate code for MD-2/3 ROM 1.x
  651. ;
  652.      IF    MD3R1
  653. OK300:    MVI    A,1        ;MSPEED 300 BAUD VALUE
  654.     JMP    GETBAUD        ;GO LOAD THEM
  655. OK1200:    MVI    A,5        ;MSPEED 1200 BAUD VALUE
  656.     JMP    GETBAUD        ;GO LOAD THEM
  657. OK2400:    RET            ;NEED AN OK2400 LABEL
  658. ;
  659. GETBAUD:
  660.     STA    MSPEED
  661.     MVI    B,4FH        ;DIVIDE BY 64 FOR 300 BAUD
  662.     CPI    1
  663.     JZ    LOADBD
  664.     MVI    B,04EH        ;DIVIDE BY 16 FOR 1200 BAUD (DEFAULT)
  665. LOADBD:    STA    MSPEED        ;CHANGE TIME-TO-SEND TO MATCH BAUDRATE
  666.     MOV    A,B        ;GET BAUDRATE BYTE
  667.     OUT    MDCTL1        ;MODEM STATUS PORT
  668.     IN    MDDATP        ;READ IN ANY GARBAGE
  669.     RET
  670.      ENDIF            ;MD3R1
  671.  
  672. ;=============================================================================
  673. ;
  674. ;Common baud rate code for MD-2/3 ROM's 2.x and 3.x and MD-HD
  675. ;
  676.      IF    (NOT MD3R1)
  677. OK110:    MVI    A,0        ; MSPEED 110 baud value
  678.     JMP    GETBAUD
  679. OK300:    MVI    A,1
  680.     JMP    GETBAUD
  681. OK450:    MVI    A,2
  682.     JMP    GETBAUD
  683. OK600:    MVI    A,3
  684.     JMP    GETBAUD
  685. OK710:    MVI    A,4
  686.     JMP    GETBAUD
  687. OK1200:    MVI    A,5
  688.     JMP    GETBAUD
  689. OK2400:    MVI    A,6
  690.     JMP    GETBAUD
  691. OK4800:    MVI    A,7
  692.     JMP    GETBAUD
  693. OK9600:    MVI    A,8
  694.     JMP    GETBAUD
  695. OK19200:MVI    A,9
  696.      ENDIF
  697.  
  698. ;=============================================================================
  699. ;
  700. ;Code to swap ports on the MD-HD
  701. ;
  702.      IF    (MDHDA OR MDHDP)
  703. OKPM:
  704.     MVI    A,062H
  705.     STA    BSPRT
  706.     LXI    H,7E51H
  707.     SHLD    BRPRT
  708.     JMP    INITMOD
  709.  
  710. OKAUX:
  711.     MVI    A,070H
  712.     STA    BSPRT
  713.     LXI    H,3E50H
  714.     SHLD    BRPRT
  715.     JMP    INITMOD
  716.      ENDIF
  717.  
  718. ;=============================================================================
  719. ;
  720. ;Common baud rate code for MD-2/3 ROM's 2.x and 3.x and MD-HD
  721. ;
  722.      IF    (NOT MD3R1)
  723. GETBAUD:
  724.     PUSH    PSW
  725.     LXI    H,BDTAB
  726.     ADD    A        ;*2
  727.     MOV    E,A
  728.     MVI    D,0
  729.     DAD    D
  730.     MOV    A,M
  731.     INX    H
  732.     MOV    H,M
  733.     MOV    L,A        ;HL = baud rate divisor
  734.     POP    PSW        ;falls through to LOADBD
  735.      ENDIF
  736.  
  737. ;=============================================================================
  738. ;
  739. ;Baud rate code for MD-2/3 ROM's 2.x and 3.x
  740. ;
  741.      IF    MD3R2
  742. LOADBD:
  743.     STA     MSPEED
  744.     MVI    A,CTCSEL
  745.     OUT    CPORT
  746.     MOV    A,L
  747.     OUT    BPORT
  748.     MOV    A,H
  749.     OUT    BPORT
  750.     RET
  751.      ENDIF
  752.  
  753. ;=============================================================================
  754. ;
  755. ;Baud rate code for MD-HD
  756. ;
  757.      IF    (MDHDA OR MDHDP)
  758. LOADBD:    STA    MSPEED        ; Change time-to-send to match baudrate
  759.     LDA    BMD
  760.     OUT    MOPORT
  761.     PUSH    B
  762.     LDA    BRPRT
  763.     MOV    C,A
  764.     MOV    A,L
  765. ;    out    (c),a
  766.     dw    79edh
  767.     MOV    A,H
  768. ;    out    (c),a
  769.     dw    79edh
  770.     POP    B
  771.     RET
  772.      ENDIF            ;(MDHDA OR MDHDP)
  773.  
  774. ;=============================================================================
  775. ;
  776. ; Table of baud rate values for MD-2/3 ROM's 2.x and 3.x
  777. ;
  778.      IF    MD3R2
  779. BDTAB:
  780.     DW    1136        ; 110 baud                 
  781.     DW    417         ; 300 baud                 
  782.     DW    278         ; 450 baud
  783.     DW    208         ; 600 baud                 
  784.     DW    0           ; 710 baud (Not supported)
  785.     DW    104         ; 1200 baud                
  786.     DW    52          ; 2400 baud                
  787.     DW    26          ; 4800 baud                
  788.     DW    13          ; 9600 baud                
  789.     DW    0           ;19200 baud (Not supported)
  790.      ENDIF            ;MD3R2
  791.  
  792. ;=============================================================================
  793. ;
  794. ; Table of baud rate values for MD-HD
  795. ;
  796.      IF    (MDHDA OR MDHDP)
  797. BDTAB:
  798.     DW    1136*2        ; 110 baud
  799.     DW    417*2        ; 300 baud
  800.     DW    0        ; 450 baud (Not supported)
  801.     DW    208*2        ; 600 baud
  802.     DW    0        ; 710 baud (Not supported)
  803.     DW    104*2        ; 1200 baud
  804.     DW    52*2        ; 2400 baud
  805.     DW    26*2        ; 4800 baud
  806.     DW    13*2        ; 9600 baud
  807.     DW    13        ;19200 baud                
  808.      ENDIF            ;(MDHDA OR MDHDP)
  809. ;
  810. BAUDBUF:DB    10,0,0,0,0,0
  811.     DB    0,0,0,0,0
  812. ;
  813. ;                   end
  814. ;-----------------------------------------------------------------------
  815. ;
  816. ; NOTE: Must terminate prior to 0400H
  817. ;
  818.     END
  819. SPL: DS    3        ; Allows entry of baudrate on CMD line    16EH
  820. J$CRL