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 / M7US-2.AQM / M7US-2.ASM
Assembly Source File  |  2000-06-30  |  13KB  |  374 lines

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