home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols100 / vol168 / m7us-1.asm < prev    next >
Encoding:
Assembly Source File  |  1994-07-13  |  12.9 KB  |  373 lines

  1. ; M7US-1.ASM -- U.S. Robotics S-100 overlay for MDM7xx.  12/21/83
  2. ;
  3. ; This overlay adapts the MDM7xx program to the U.S. Robotics S-100
  4. ; autodial modem.
  5. ;
  6. ; You will want to look this file over carefully. There are a number of
  7. ; options that you can use to configure the program to suit your taste.
  8. ;
  9. ; This overlay is capable of setting the baud rate and sending breaks.
  10. ; Although disconnecting the modem is not supported (by use of a function
  11. ; to lower DTR), the control-N command still works, as it uses "+++"
  12. ; which causes the U.S.R. S-100 modem to hang up.  If you are running a
  13. ; system which has a clock speed of more than 4 MHz, be sure to see
  14. ; the routine INITMOD, as you will have to "uncomment" some do-nothing
  15. ; time wasting statements to slow your computer down for the modem.
  16. ;
  17. ;
  18. ;    TO USE: First edit this file filling in answers for your own
  19. ;        equipment.  Then assemble with ASM.COM or equivalent
  20. ;        assembler.  Then use DDT to overlay the the results
  21. ;        of this program to the original .COM file:
  22. ;
  23. ;        A>DDT MDM7xx.COM
  24. ;        DDT VERS 2.2
  25. ;        NEXT  PC
  26. ;        4300 0100
  27. ;        -IM7US-1.HEX        (note the "I" command)
  28. ;        -R            ("R" loads in the .HEX file)
  29. ;        NEXT  PC
  30. ;        4300 0000
  31. ;        -G0            (return to CP/M)
  32. ;        A>SAVE 66 MDM7xx.COM    (now have a modified .COM file)
  33. ;
  34. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  35. ;
  36. ; 12/21/83 - Added "commented" delays in init-
  37. ;         ialization for fast systems.    - Phil Lapsley
  38. ; 12/19/83 - Now sends AT command in the
  39. ;            initialization routine to get
  40. ;            the attention of the USR S-100     - Phil Lapsley
  41. ; 12/17/83 - Created from M7GP-1.ASM        - Phil Lapsley
  42. ; 11/11/83 - Renamed to M7GP-1.ASM, no changes    - Irv Hoff
  43. ; 07/27/83 - Renamed to work with MDM712    - Irv Hoff
  44. ; 07/01/83 - Revised to work with MDM711    - Irv Hoff
  45. ; 07/01/83 - Revised to work with MDM710    - Irv Hoff
  46. ; 05/27/83 - Updated to work with MDM709    - Irv Hoff
  47. ; 05/15/83 - Revised to work with MDM708    - Irv Hoff
  48. ; 04/11/83 - Updated to work with MDM707    - Irv Hoff
  49. ; 04/04/83 - First version of this file        - Irv Hoff
  50. ;
  51. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  52. ;
  53. BELL:        EQU    07H        ;bell
  54. CR:        EQU    0DH        ;carriage return
  55. ESC:        EQU    1BH        ;escape
  56. LF:        EQU    0AH        ;linefeed
  57. ;
  58. YES:        EQU    0FFH
  59. NO:        EQU    0
  60. ;
  61. ;
  62. ; Change the following information to match your equipment
  63. ;
  64. PORT:        EQU    000H
  65. MODCTL1:    EQU    PORT+1        ;MODEM CONTROL PORT
  66. MODDATP:    EQU    PORT        ;MODEM DATA IN PORT
  67. MODDATO:    EQU    PORT        ;MODEM DATA OUT PORT
  68. MODDCDB:    EQU    080H        ;CARRIER DETECT BIT
  69. MODDCDA:    EQU    080H        ;VALUE WHEN ACTIVE
  70. MODRCVB:    EQU    2        ;BIT TO TEST FOR RECEIVE
  71. MODRCVR:    EQU    2        ;VALUE WHEN READY
  72. MODSNDB:    EQU    1        ;BIT TO TEST FOR SEND
  73. MODSNDR:    EQU    1        ;VALUE WHEN READY
  74. ;
  75.         ORG    100H
  76. ;
  77. ;
  78. ; Change the clock speed to suit your system
  79. ;
  80.         DS    3    ;(for  "JMP   START" instruction)
  81. ;
  82. PMMIMODEM:    DB    NO    ;yes=PMMI S-100 Modem            103H
  83. SMARTMODEM:    DB    YES    ;yes=HAYES Smartmodem, no=non-PMMI    104H
  84. TOUCHPULSE:    DB    'T'    ;T=touch, P=pulse (Smartmodem-only)    105H
  85. CLOCK:        DB    50    ;clock speed in MHz x10, 25.5 MHz max.    106H
  86.                 ;20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  87. MSPEED:        DB    1    ;0=110 1=300 2=450 3=600 4=710 5=1200    107H
  88.                 ;6=2400 7=4800 8=9600 9=19200 default
  89. BYTDLY:        DB    5    ;0=0 delay  1=10ms  5=50 ms - 9=90 ms    108H
  90.                 ;default time to send character in ter-
  91.                 ;minal mode file transfer for slow BBS.
  92. CRDLY:        DB    5    ;0=0 delay 1=100 ms 5=500 ms - 9=900 ms 109H
  93.                 ;default time for extra wait after CRLF
  94.                 ;in terminal mode file transfer
  95. NOOFCOL:    DB    5    ;number of DIR columns shown        10AH
  96. SETUPTST:    DB    YES    ;yes=user-added Setup routine        10BH
  97. SCRNTEST:    DB    NO    ;Cursor control routine         10CH
  98. ACKNAK:        DB    YES    ;yes=resend a record after any non-ACK    10DH
  99.                 ;no=resend a record after a valid-NAK
  100. BAKUPBYTE:    DB    NO    ;yes=change any file same name to .BAK    10EH
  101. CRCDFLT:    DB    YES    ;yes=default to CRC checking        10FH
  102. TOGGLECRC:    DB    YES    ;yes=allow toggling of CRC to Checksum    110H
  103. CONVBKSP:    DB    NO    ;yes=convert backspace to rub        111H
  104. TOGGLEBK:    DB    YES    ;yes=allow toggling of bksp to rub    112H
  105. ADDLF:        DB    NO    ;no=no LF after CR to send file in    113H
  106.                 ;terminal mode (added by remote echo)
  107. TOGGLELF:    DB    YES    ;yes=allow toggling of LF after CR    114H
  108. TRANLOGON:    DB    YES    ;yes=allow transmission of logon    115H
  109.                 ;write logon sequence at location LOGON
  110. SAVCCP:        DB    YES    ;yes=do not overwrite CCP        116H
  111. LOCONEXTCHR:    DB    NO    ;yes=local command if EXTCHR precedes    117H
  112.                 ;no=external command if EXTCHR precedes
  113. TOGGLELOC:    DB    YES    ;yes=allow toggling of LOCONEXTCHR    118H
  114. LSTTST:        DB    YES    ;yes=printer available on printer port    119H
  115. XOFFTST:    DB    NO    ;yes=checks for XOFF from remote while    11AH
  116.                 ;sending a file in terminal mode
  117. XONWAIT:    DB    NO    ;yes=wait for XON after CR while    11BH
  118.                 ;sending a file in terminal mode
  119. TOGXOFF:    DB    YES    ;yes=allow toggling of XOFF checking    11CH
  120. IGNORCTL:    DB    YES    ;yes=CTL-chars above ^M not displayed    11DH
  121. EXTRA1:        DB    0    ;for future expansion            11EH
  122. EXTRA2:        DB    0    ;for future expansion            11FH
  123. BRKCHR:        DB    '@'-40H    ;^@ = Send 300 ms. break tone        120H
  124. NOCONNCT:    DB    'N'-40H    ;^N = Disconnect from the phone line    121H
  125. LOGCHR:        DB    'L'-40H    ;^L = Send logon            122H
  126. LSTCHR:        DB    'P'-40H    ;^P = Toggle printer            123H
  127. UNSAVE:        DB    'R'-40H    ;^R = Close input text buffer        124H
  128. TRANCHR:    DB    'T'-40H ;^T = Transmit file to remote        125H
  129. SAVECHR:    DB    'Y'-40H    ;^Y = Open input text buffer        126H
  130. EXTCHR:        DB    '^'-40H    ;^^ = Send next character        127H
  131. ;
  132. ;
  133.         DS    2        ;                128H
  134. ;
  135. IN$MODCTL1:    IN    MODCTL1    ! RET    ;in modem control port        12AH
  136.         DS    7
  137. OUT$MODDATP:    OUT    MODDATP ! RET    ;out modem data port        134H
  138.         DS    7
  139. IN$MODDATP:    IN    MODDATP ! RET    ;in modem data port        13EH
  140.         DS    7
  141. ANI$MODRCVB:    ANI    MODRCVB    ! RET    ;bit to test for receive ready    148H
  142.  
  143. CPI$MODRCVR:    CPI    MODRCVR    ! RET    ;value of rcv. bit when ready    14BH
  144. ANI$MODSNDB:    ANI    MODSNDB    ! RET    ;bit to test for send ready    14EH
  145. CPI$MODSNDR:    CPI    MODSNDR    ! RET    ;value of send bit when ready    151H
  146.         DS    6        ;                156H
  147. ;
  148. OUT$MODCTL1:    OUT    MODCTL1    ! RET    ;out modem control port #1    15AH
  149. OUT$MODCTL2:    RET  !    NOP  !  NOP    ;ctl-port #2 is not used    15DH
  150. ;
  151. LOGONPTR:    DW    LOGON        ;for user message.        160H
  152.         DS    6        ;                162H
  153. JMP$GOODBYE:    JMP    GOODBYE        ;                168H
  154. JMP$INITMOD:    JMP    INITMOD        ;go to user written routine    16BH
  155.         RET  !    NOP  !    NOP    ;(by-passes PMMI routine)    16EH
  156.         RET  !    NOP  !    NOP    ;(by-passes PMMI routine)    171H
  157.         RET  !    NOP  !    NOP    ;(by-passes PMMI routine)    174H
  158. JMP$SETUPR:    JMP    SETUPR        ;                177H
  159. JMP$SPCLMENU:    JMP    SPCLMENU    ;                17AH
  160. JMP$SYSVER:    JMP    SYSVER        ;                17DH
  161. JMP$BREAK:    JMP    SENDBRK        ;                180H
  162. ;
  163. ;
  164. ; Do not change the following six lines.
  165. ;
  166. JMP$ILPRT:    DS    3        ;                183H
  167. JMP$INBUF    DS    3        ;                186H
  168. JMP$INLNCOMP:    DS    3        ;                189H
  169. JMP$INMODEM    DS    3        ;                18CH
  170. JMP$NXTSCRN:    DS    3        ;                18FH
  171. JMP$TIMER    DS    3        ;                192H
  172. ;
  173. ;
  174. ; Routine to clear to end of screen.  If using CLREOS and CLRSCRN, set
  175. ; SCRNTEST to YES at 010AH (above).
  176. ;
  177. CLREOS:        CALL    JMP$ILPRT    ;                195H
  178.         DB    0,0,0,0,0    ;                198H
  179.         RET            ;                19DH
  180. ;
  181. CLRSCRN:    CALL    JMP$ILPRT    ;                19EH
  182.         DB    0,0,0,0,0    ;                1A1H
  183.         RET            ;                1A6H
  184.     
  185. ;
  186. SYSVER:        CALL    JMP$ILPRT    ;                1A7H
  187.         DB    'Version for U.S.R. S-100 autodial'
  188.         DB    CR,LF,0
  189.         RET
  190. ;.....
  191. ;
  192. ;
  193. ;-----------------------------------------------------------------------
  194. ;
  195. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  196. ;     end of your last routine should terminate by 0400H (601 bytes
  197. ;     available after start of SYSVER) if using the Hayes Smartmodem
  198. ;     or by address 0C00H (2659 bytes) otherwise.
  199. ;
  200. ;-----------------------------------------------------------------------
  201. ;
  202. ; You can put in a message at this location which can be called up with
  203. ; CTL-O if TRANLOGON has been set TRUE.  You can use several lines if
  204. ; desired.  End with a 0.
  205. ;
  206. LOGON:        DB    'How are you today?',CR,LF,0
  207. ;.....
  208. ;
  209. ;
  210. ; The following routine sends a break "character" to the remote
  211. ; computer for 300 ms.  The "MSPEED" value is needed to decide whether
  212. ; or not the modem is at 300, 600, or 1200 baud.  The routine must
  213. ; know this because U.S.R. set up the RTS bit of the command resgister
  214. ; as a baud rate selection bit, and this routine must be careful not
  215. ; to change it, or the user will end up at a different baud rate
  216. ; after the break "character" is sent.  Note that the "MVI A, 01FH" does
  217. ; not change any flags.
  218. ;
  219. SENDBRK:    LDA    MSPEED        ; Get speed byte
  220.         CPI    3        ; Are we at 600 baud?
  221.         MVI    A, 01FH        ; Set up for 600 (no flag changes)
  222.         JZ    SBRK2        ; And if we are, go do that
  223.         MVI    A, 03FH        ; Otherwise, set up for 300/1200
  224. SBRK2:        OUT    MODCTL1        ; Send break
  225.         PUSH    PSW        ; Save value
  226.         MVI    B, 3        ; 300 ms delay value
  227.         CALL    JMP$TIMER    ; Wait that long
  228.         POP    PSW        ; Restore command byte
  229.         ANI    0F7H        ; Turn off break bit
  230.         OUT    MODCTL1        ; Send command byte to UART
  231.         RET
  232. ;.....
  233. ;
  234. ;
  235. ; The U.S.R. S-100 does not have a "quick-disconnect" feature like
  236. ; the Hayes does (by lowering DTR).  Therefore, "GOODBYE" is not
  237. ; implemented.  Yet control-N still works to hang up (see note
  238. ; above in introduction)
  239. ;
  240. GOODBYE:    RET
  241. ;.....
  242. ;
  243. ;
  244. ; You can use this area for any special initialization or setup you may
  245. ; wish to include.  Each must stop with a RET.    This initialization
  246. ; sets up 300 baud, 8 data bits, 1 stop bit, no parity.  Due to a
  247. ; quirk in the U.S.R. S-100 (it seems to have plenty of 'em), after
  248. ; you change baud rates, you should send an "AT" followed by a
  249. ; carriage return.  Therefore, this is done after every initialization
  250. ; when there is no carrier present.
  251. ;
  252. ; NOTE: The U.S.R. S-100 does not operate too well at clock speeds of
  253. ;    over 4 MHz.  If you are running at that speed or higher, you
  254. ;    should uncomment (by removing the preceding semicolon) the
  255. ;    lines with XCHG.  These serve as time wasting routines to
  256. ;    let the U.S.R. S-100 catch up.  This is not a problem when
  257. ;    doing character I/O, as the program checks to see if the
  258. ;    modem is ready to accept a character.
  259. ;
  260. INITMOD:      XRA    A        ; Zero accumulator
  261.         OUT    MODCTL1        ; Clear 8251A
  262. ;        XCHG            ; For fast systems
  263. ;        XCHG            ; For fast systems
  264.         OUT    MODCTL1        ; Twice
  265. ;        XCHG            ; For fast systems
  266. ;        XCHG            ; For fast systems
  267.         OUT    MODCTL1        ; Three times, even
  268. ;        XCHG            ; For fast systems
  269. ;        XCHG            ; For fast systems
  270.         MVI    A, 040H        ; Reset UART command
  271.         OUT    MODCTL1
  272. ;        XCHG            ; For fast systems
  273. ;        XCHG            ; For fast systems
  274. MODEBT:        MVI    A, 04FH        ; 8 bits, 1 stop, no parity
  275.         OUT    MODCTL1
  276. ;        XCHG            ; For fast systems
  277. ;        XCHG            ; For fast systems
  278. CMDBT:        MVI    A, 037H        ; On hook, Tx/Rx enable, reset errs
  279.         OUT    MODCTL1
  280. ;        XCHG            ; For fast systems
  281. ;        XCHG            ; For fast systems
  282. BDCODE:        MVI    A, 1        ; 300 baud code
  283.         STA    MSPEED
  284.         IN    MODCTL1        ; Get the current status
  285.         ANI    MODDCDB        ; See if there is a carrier
  286.         RNZ            ; If so, don't do AT stuff
  287.         MVI    B, 1        ; 100 ms
  288.         CALL    JMP$TIMER    ; Wait that long for things to settle
  289.         MVI    B, 'A'        ; "A" of AT command
  290.         CALL    OUTMOD        ; Output to the modem
  291.         MVI    B, 'T'        ; "T" of AT command
  292.         CALL    OUTMOD        ; Output
  293.         MVI    B, CR        ; Followed by a carriage return
  294.         CALL    OUTMOD        ; Output that too
  295.         RET
  296. ;
  297. ; Output a character to the U.S.R. S-100
  298. ; (NOTE: This routine is not normally present in most overlays,
  299. ;      and is used by the INITMOD routine above.)
  300. ;
  301. OUTMOD        IN    MODCTL1        ; Get status
  302.         ANI    MODSNDB        ; Mask for ready status
  303.         JZ    OUTMOD        ; Loop if not ready
  304.         MOV    A, B        ; Otherwise get the character
  305.         OUT    MODDATP        ; Output to the data port
  306.         RET            ; And return
  307.  
  308. ;
  309. ; This routine prompts the user for a new baud rate
  310. ; (on the U.S.R. this can be 300, 600, or 1200, as mdm7xx
  311. ; has no provision for 150 baud) and sets the modem to that
  312. ; baud rate.
  313. ;
  314. SETUPR:        LXI    D, BAUDBUF    ; Point to new input buffer
  315.         CALL    JMP$ILPRT    ; Print following line:
  316.         DB    'Input baud rate (300, 600, 1200): ', 0
  317.         CALL    JMP$INBUF    ; Get a line into the buffer
  318.         LXI    D, BAUDBUF + 2    ; compare BAUDBUF+2 with characters
  319.         CALL    JMP$INLNCOMP
  320.         DB    '300', 0
  321.         JNC    OK300
  322.         CALL    JMP$INLNCOMP
  323.         DB    '600', 0
  324.         JNC    OK600
  325.         CALL    JMP$INLNCOMP
  326.         DB    '1200', 0
  327.         JNC    OK1200
  328.         CALL    JMP$ILPRT
  329.         DB    '++ Incorrect entry ++', CR, LF, BELL, 0
  330.         JMP    SETUPR        ; Try again
  331. ;
  332. OK300:        LXI    B, BD300    ; Point to intializers for 300 baud
  333.         MVI    A, 1        ; 300 baud value
  334.         JMP    LOADBD        ; Go load it
  335. ;
  336. OK600:        LXI    B, BD600
  337.         MVI    A, 3
  338.         JMP    LOADBD
  339. ;
  340. OK1200:        LXI    B, BD1200
  341.         MVI    A, 5
  342. ;
  343. LOADBD:        STA    BDCODE + 1    ; Change baud rate code value
  344.         LDAX    B        ; Get mode byte value
  345.         STA    MODEBT + 1    ; Change mode byte
  346.         INX    B        ; Point to cmd byte
  347.         LDAX    B        ; Get cmd byte
  348.         STA    CMDBT + 1    ; Change cmd byte
  349.         JMP    INITMOD        ; (Re)initialize modem
  350. ;
  351. ; Baudrate parameters (mode byte, command byte)
  352. ; All values give 8 data bits, 1 stop bit, no parity.
  353. ;
  354. BD300:        DB    04FH, 037H    ; 300 baud
  355. BD600:        DB    04EH, 017H    ; 600 baud
  356. BD1200:        DB    04EH, 037H    ; 1200 baud
  357. ;
  358. BAUDBUF:    DB    10, 0
  359.         DS    10
  360. ;
  361. ; If using the Hayes Smartmodem this is unavailable without a special
  362. ; change.
  363. ;
  364. SPCLMENU:  RET
  365. ;
  366. ;
  367. ; NOTE:  MUST TERMINATE PRIOR TO 0400H (with Smartmodem)
  368. ;                 0C00H (without Smartmodem)
  369. ;.....
  370. ;
  371.       END
  372. ;
  373.