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 / M7PC-1.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  12KB  |  496 lines

  1. ; M7PC-1.ASM -- Overlay for IBM PC With a Baby Blue Z80 CPU for MDM7xx.
  2. ; 11/11/83
  3. ;
  4. ; This overlay adapts the MDM7xx program to the IBM PC With a Baby Blue
  5. ; Z-80 CPU card.
  6. ;
  7. ; Some Z-80 code is used in this overlay to allow it to fit inside of
  8. ; 400H.  (Start of dialing routines.)  It is included by some EQU's at
  9. ; the beginning.  DO NOT REMOVE THEM.
  10. ;
  11. ; You will want to look this file over carefully. There are a number of
  12. ; options that you can use to configure the program to suit your taste.
  13. ;
  14. ; The 'SET' command can be used to change the baud rate to a selected
  15. ; value.  It comes up at 300 baud.
  16. ;
  17. ; Edit this file for your preferences then follow the "TO USE:" example
  18. ; shown below.
  19. ;
  20. ;    TO USE: First edit this file filling in answers for your own
  21. ;        equipment.  Then assemble with ASM.COM or equivalent
  22. ;        assembler.  Then use DDT to overlay the the results
  23. ;        of this program to the original .COM file:
  24. ;
  25. ;        A>DEBUG DDT.COM
  26. ;        -G
  27. ;        DDT VERS 2.2
  28. ;        -I MDM7xx.COM       (Original version with bound header)
  29. ;        -R
  30. ;        NEXT  PC
  31. ;        4300 0100
  32. ;        -IM7PC-1.HEX       (note the "I" command)
  33. ;        -R           ("R" loads in the .HEX file)
  34. ;        NEXT  PC
  35. ;        4300 0000
  36. ;        -G0           (return to CP/M)
  37. ;        Program terminated normally
  38. ;        -RCS
  39. ;        CS xxxx           (present code seg. pointer)
  40. ;        :1000           (segment address of Baby Blue memory)
  41. ;        -RCS
  42. ;        CX xxxx
  43. ;        :4200           (size of program to be saved)
  44. ;        -NMDM7xx.CPM       (note extention .CPM not .COM)
  45. ;        -W           (write the file)
  46. ;        Writing 4200 bytes
  47. ;        -Q           (exit from debug)
  48. ;        A>BIND MDM7xx.CPM  (bind on the header to all programs
  49. ;                     to run under CP/M)
  50. ;
  51. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  52. ;
  53. ; 11/11/83 - Renamed to M7PC-1.ASM, no changes    - Irv Hoff
  54. ; 09/04/83 - Adapted to IBM PC With a Baby Blue Z80 CPU from
  55. ;         MDM710OT.ASM (Otrona)        - David Rounds
  56. ;    
  57. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  58. ;
  59. ;======================Z80 BRANCH EQUATES===============================
  60. ;
  61. ;
  62. BNC    EQU    30H
  63. BZ    EQU    28H
  64. BR    EQU    18H
  65. BC    EQU    38H
  66. BNZ    EQU    20H
  67. ;
  68. ;;; EXAMPLE OF USE OF Z80 BRANCH INSTRUCTIONS
  69. ;;;
  70. ;;;        ORG    100H
  71. ;;;
  72. ;;;  NEXT:  DB     BR,START-NEXT-2 AND 0FFH  ;branch to start:
  73. ;;;  START: DB     BR,NEXT-START-2 AND 0FFH  ;branch to next:
  74. ;;;
  75. ;;;        END  100H
  76. ;;;
  77. ;=======================================================================
  78. ;
  79. ;
  80. ;
  81. BELL:        EQU    07H        ;bell
  82. CR:        EQU    0DH        ;carriage return
  83. ESC:        EQU    1BH        ;escape
  84. LF:        EQU    0AH        ;linefeed
  85. CLS:        EQU    1AH        ;clear screen
  86. ;
  87. ;
  88. ; BDOS EQUATES
  89. ;
  90. BDOS:        EQU    0005H
  91. WRCON:        EQU    02H
  92. RDCON:        EQU    01H
  93. PUNCH:        EQU    04H
  94. ;
  95. ;
  96. ;
  97. YES:        EQU    0FFH
  98. NO:        EQU    0
  99. ;
  100. ;
  101. PORT        EQU    03F8H
  102. MODCTL1        EQU    PORT+3        ;line control register
  103. MODCTL2        EQU    PORT+4        ;modem control register
  104. MODDATO        EQU    PORT        ;data out port
  105. MODDATP        EQU    PORT        ;data in port
  106. MODST1        EQU    PORT+5        ;line status register
  107. MODST2        EQU    PORT+6        ;modem status register
  108. ;
  109. MODRCVB        EQU    01H
  110. MODRCVR        EQU    01H
  111. MODSNDB        EQU    20H
  112. MODSNDR        EQU    20H
  113. ;
  114. ;
  115.         ORG    100H
  116. ;
  117. ;
  118. ;
  119.         DS    3    ;(for  "JMP   START" instruction)
  120. ;
  121. PMMIMODEM:    DB    NO    ;yes=PMMI S-100 Modem            103H
  122. SMARTMODEM:    DB    NO    ;yes=HAYES Smartmodem, no=non-PMMI    104H
  123. TOUCHPULSE:    DB    'T'    ;T=touch, P=pulse (Smartmodem-only)    105H
  124. CLOCK:        DB    25    ;clock speed in MHz x10, 25.5 MHz max.    106H
  125.                 ;20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  126. MSPEED:        DB    5    ;0=110 1=300 2=450 3=600 4=710 5=1200    107H
  127.                 ;6=2400 7=4800 8=9600 9=19200 default
  128. BYTDLY:        DB    5    ;0=0 delay  1=10ms  5=50 ms - 9=90 ms    108H
  129.                 ;default time to send character in ter-
  130.                 ;minal mode file transfer for slow BBS.
  131. CRDLY:        DB    5    ;0=0 delay 1=100 ms 5=500 ms - 9=900 ms 109H
  132.                 ;default time for extra wait after CRLF
  133.                 ;in terminal mode file transfer
  134. NOOFCOL:    DB    5    ;number of DIR columns shown        10AH
  135. SETUPTST:    DB    YES    ;yes=user-added Setup routine        10BH
  136. SCRNTEST:    DB    YES    ;Cursor control routine         10CH
  137. ACKNAK:        DB    YES    ;yes=resend a record after any non-ACK    10DH
  138.                 ;no=resend a record after a valid-NAK
  139. BAKUPBYTE:    DB    NO    ;yes=change any file same name to .BAK    10EH
  140. CRCDFLT:    DB    YES    ;yes=default to CRC checking        10FH
  141. TOGGLECRC:    DB    YES    ;yes=allow toggling of CRC to Checksum    110H
  142. CONVBKSP:    DB    NO    ;yes=convert backspace to rub        111H
  143. TOGGLEBK:    DB    YES    ;yes=allow toggling of bksp to rub    112H
  144. ADDLF:        DB    NO    ;no=no LF after CR to send file in    113H
  145.                 ;terminal mode (added by remote echo)
  146. TOGGLELF:    DB    YES    ;yes=allow toggling of LF after CR    114H
  147. TRANLOGON:    DB    YES    ;yes=allow transmission of logon    115H
  148.                 ;write logon sequence at location LOGON
  149. SAVCCP:        DB    YES    ;yes=do not overwrite CCP        116H
  150. LOCONEXTCHR:    DB    NO    ;yes=local command if EXTCHR precedes    117H
  151.                 ;no=external command if EXTCHR precedes
  152. TOGGLELOC:    DB    YES    ;yes=allow toggling of LOCONEXTCHR    118H
  153. LSTTST:        DB    YES    ;yes=allow toggling of printer on/off    119H
  154. ;
  155. ;
  156. ; Change the following to match the needs of the computer you will be
  157. ; to using terminal (T) (non-protocal)
  158. ;
  159. XOFFTST:    DB    NO    ;yes=checks for XOFF from remote while    11AH
  160.                 ;sending a file in terminal mode
  161. XONWAIT:    DB    NO    ;yes=wait for XON after CR while    11BH
  162.                 ;sending a file in terminal mode
  163. ;
  164. ;
  165. TOGXOFF:    DB    YES    ;yes=allow toggling of XOFF checking    11CH
  166. IGNORCTL:    DB    YES    ;yes=CTL-chars above ^M not displayed    11DH
  167. EXTRA1:        DB    0    ;for future expansion            11EH
  168. EXTRA2:        DB    0    ;for future expansion            11FH
  169. BRKCHR:        DB    '@'-40H    ;^@ = Send 300 ms. break tone        120H
  170. NOCONNCT:    DB    'N'-40H    ;^N = Disconnect from the phone line    121H
  171. LOGCHR:        DB    'L'-40H    ;^L = Send logon            122H
  172. LSTCHR:        DB    'P'-40H    ;^P = Toggle printer            123H
  173. UNSAVE:        DB    'R'-40H    ;^R = Close input text buffer        124H
  174. TRANCHR:    DB    'T'-40H ;^T = Transmit file to remote        125H
  175. SAVECHR:    DB    'Y'-40H    ;^Y = Open input text buffer        126H
  176. EXTCHR:        DB    'U'-40H    ;^^ = Send next character        127H
  177. ;
  178. ;
  179.         DS    2        ;                128H
  180. ;
  181. IN$MODST1:    CALL    XSTATUS ! RET    ;read status port 1        12AH
  182.         DS    6
  183. OUT$MODDATP:    CALL    XOUTPUT ! RET    ;write to output        134H
  184.         DS    6
  185. IN$MODDATP:    CALL    XINPUT ! RET    ;read from input        13EH
  186.         DS    6
  187. ANI$MODRCVB:    ANI    MODRCVB    ! RET    ;bit to test for receive ready    148H
  188.  
  189. CPI$MODRCVR:    CPI    MODRCVR    ! RET    ;value of rcv. bit when ready    14BH
  190. ANI$MODSNDB:    ANI    MODSNDB    ! RET    ;bit to test for send ready    14EH
  191. CPI$MODSNDR:    CPI    MODSNDR    ! RET    ;value of send bit when ready    151H
  192.         DS    6        ;                156H
  193. ;
  194. OUT$MODCTL1    JMP    CONTRL1        ;write to control port #1    15AH
  195. OUT$MODCTL2:    JMP    CONTRL2        ;write to control port #2    15DH
  196. ;
  197. LOGONPTR:    DW    LOGON        ;for user message.        160H
  198.         DS    6        ;                162H
  199. JMP$GOODBYE:    JMP    GOODBYE        ;                168H
  200. JMP$INITMOD:    JMP    INITMOD        ;go to user written routine    16BH
  201. ;
  202.         RET  !    NOP  !    NOP    ; bypass PMII routine        16EH
  203.         RET  !    NOP  !    NOP    ; bypass PMII routine        171H
  204.         RET  !    NOP  !    NOP    ; bypass PMII routine        174H
  205. ;
  206. JMP$SETUPR:    JMP    SETUPR        ;                177H
  207. JMP$SPCLMENU:    JMP    SPCLMENU    ;                17AH
  208. JMP$SYSVER:    JMP    SYSVER        ;                17DH
  209. JMP$BREAK:    JMP    SENDBRK        ;                180H
  210. ;
  211. ;
  212. ; Do not change the following six lines.
  213. ;
  214. JMP$ILPRT:    DS    3        ;                183H
  215. JMP$INBUF    DS    3        ;                186H
  216. JMP$INLNCOMP:    DS    3        ;                189H
  217. JMP$INMODEM    DS    3        ;                18CH
  218. JMP$NXTSCRN:    DS    3        ;                18FH
  219. JMP$TIMER    DS    3        ;                192H
  220. ;
  221. ;
  222. ; Routine to clear to end of screen.  If using CLREOS and CLRSCRN, set
  223. ; SCRNTEST to YES at 010AH (above).
  224. ;
  225. CLREOS:        CALL    JMP$ILPRT    ;                195H
  226.         DB    ESC,'Y',0,0,0    ;                198H
  227.         RET            ;                19DH
  228. ;
  229. CLRSCRN:    CALL    JMP$ILPRT    ;                19EH
  230.         DB    CLS,0,0,0,0    ;                1A1H
  231.         RET            ;                1A6H
  232.     
  233. ;
  234. SYSVER:        CALL    JMP$ILPRT    ;                1A7H
  235.         DB    CR,LF,'IBM PC  With Baby Blue CP/M card'
  236.         DB    CR,LF,LF,0
  237.         RET
  238. ;.....
  239. ;
  240. ;
  241. ;-----------------------------------------------------------------------
  242. ;
  243. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  244. ;     end of your last routine should terminate by 0400H (601 bytes
  245. ;     available after start of SYSVER) if using the Hayes Smartmodem
  246. ;     or by address 0C00H (2659 bytes) otherwise.
  247. ;
  248. ;-----------------------------------------------------------------------
  249. ;
  250. ; You can put in a message at this location which can be called up with
  251. ; CTL-O if TRANLOGON has been set TRUE.  You can use several lines if
  252. ; desired.  End with a 0
  253. ;
  254. LOGON:      DB    'Hello from an IBM-PC with Baby Blue CP/M Card'
  255.       DB    CR,LF,0
  256. ;.....
  257. ;
  258. ;
  259. ;  IBM-PC AUX PORT CONTROL PORT OUTPUT ROUTINES
  260. ;
  261. CONTRL1:  PUSH    H
  262.       PUSH    D
  263.       PUSH    B
  264.       MOV    E,A
  265.       LXI    H,3FBH
  266.       MVI    C,0FEH
  267.       CALL    BDOS
  268.       POP    B
  269.       POP    D
  270.       POP    H
  271.       RET
  272. ;.....
  273. ;
  274. ;
  275. CONTRL2:  PUSH    H
  276.       PUSH    D
  277.       PUSH    B
  278.       MOV    E,A
  279.       LXI    H,3FCH
  280.       MVI    C,0FEH
  281.       CALL    BDOS
  282.       POP    B
  283.       POP    D
  284.       POP    H
  285.       RET
  286. ;.....
  287. ;
  288. ;
  289. XSTATUS:  PUSH    H
  290.       PUSH    D
  291.       PUSH    B
  292.       LXI    H,MODST1
  293.       MVI    C,0FFH
  294.       CALL    BDOS
  295.       POP    B
  296.       POP    D
  297.       POP    H
  298.       RET
  299. ;.....
  300. ;
  301. ;
  302. XOUTPUT:  PUSH    H
  303.       PUSH    D
  304.       PUSH    B
  305.       MOV    E,A
  306.       LXI    H,MODDATP
  307.       MVI    C,0FEH
  308.       CALL    BDOS
  309.       POP    B
  310.       POP    D
  311.       POP    H
  312.       RET
  313. ;.....
  314. ;
  315. ;
  316. XINPUT:      PUSH    H
  317.       PUSH    D
  318.       PUSH    B
  319.       LXI    H,MODDATP
  320.       MVI    C,0FFH
  321.       CALL    BDOS
  322.       POP    B
  323.       POP    D
  324.       POP    H
  325.       RET
  326. ;.....
  327. ;
  328. ;
  329. ; This routine allows a 300 ms. break tone to be sent to reset some
  330. ; time-share computers.
  331. ;
  332. SENDBRK:  MVI    A,43H        ;send a break tone
  333.       CALL    OUT$MODCTL1
  334.       JMP    GOODBYE1
  335. ;.....
  336. ;
  337. ;
  338. ; Set DTR low for 300 ms. to disconnect some modems
  339. ;
  340. GOODBYE:  MVI    A,0        ;turn off DTR    
  341.       CALL    OUT$MODCTL2
  342. ;
  343. GOODBYE1: MVI    B,3        ;wait for 300 ms.
  344.       CALL    JMP$TIMER
  345.       MVI    A,3        ;restore to normal, DTR on, 8 bits, etc.
  346.       CALL    OUT$MODCTL1
  347.       MVI    A,1
  348.       CALL    OUT$MODCTL2
  349.       RET
  350. ;.....
  351. ;
  352. ;
  353. ; The following is the initialization routine for the IBM-PC with a Baby
  354. ; Blue Z-80 CPU:
  355. ;
  356. ;
  357. INITMOD:  LXI    H,BD1200    ;set initial baud rate to 1200 baud.
  358.       JMP    LOADBD
  359. ;.....
  360. ;
  361. ;
  362. ; Setup routine to allow changing modem speed with the set command.
  363. ;
  364. SETUPR:      LDAX    D        ;get input buffer length
  365.       INX    D        ;increment pointer past entered command
  366.       INX    D        ;increment pointer past entered command
  367.       INX    D        ;increment pointer past entered command
  368.       INX    D        ;increment pointer past entered command
  369.       INX    D        ;increment pointer past entered command
  370.       CPI    3        ;length of "set" command
  371.       JNZ    SETUPX        ;process entered speed
  372.       LXI    D,BAUDBUF    ;point to new input buffer
  373.       CALL    JMP$ILPRT
  374.       DB    'Input Baud Rate (110,300,600,1200,2400,'
  375.       DB    '4800,9600,19200): ',0
  376.       CALL    JMP$INBUF
  377.       LXI    D,BAUDBUF+2
  378. ;
  379. SETUPX:      CALL    GETPOINT    ;get pointer in 'B'
  380.       MOV    A,B
  381.       CPI    0FFH
  382. ;
  383. SET1:      DB    BNZ,SET2-SET1-2 AND 0FFH ;jmp if no error
  384.       CALL    JMP$ILPRT
  385.       DB    'Bad Baud Rate Selection',CR,LF
  386.       DB    'Present Speed Unchanged.',CR,LF,LF,0
  387.       RET
  388. ;...
  389. ;
  390. ;
  391. SET2:      LXI    H,BD110        ;get starting address of table
  392.       DAD    B        ;add offset
  393.       DAD    B        ;...
  394.       MOV    A,C        ;baud rate code
  395.       STA    MSPEED        ;save it for reference
  396. ;
  397. LOADBD:   PUSH    H        ;save pointer to divisor
  398.       MVI    A,80H        ;set flag to access divisor register
  399.       CALL    OUT$MODCTL1
  400.       POP    H
  401.       PUSH    H
  402.       MOV    E,M
  403.       LXI    H,3F8H
  404.       MVI    C,0FEH
  405.       CALL    BDOS
  406.       POP    H
  407.       INX    H
  408.       MOV    E,M
  409.       LXI    H,3F9H
  410.       MVI    D,0FEH
  411.       CALL    BDOS
  412.       MVI    A,3        ;set communications parameters..
  413.       CALL    OUT$MODCTL1    ;..no parity, 8 bits
  414.       MVI    A,1
  415.       CALL    OUT$MODCTL2    ;enable dtr
  416.       RET
  417. ;.....
  418. ;
  419. ;
  420. ; Subroutine to get baud table entry number in 'B'
  421. ;
  422. GETPOINT: LXI    B,0        ;first entry=0
  423.       CALL    JMP$INLNCOMP    ;compare BAUDBUF+2 with characters below
  424.       DB    '110',0
  425.       RNC            ;go if got match
  426.       INX    B        ;first is entry 0
  427.       CALL    JMP$INLNCOMP
  428.       DB    '300',0
  429.       RNC            ;go if got match
  430. ;
  431.       INX    B
  432.       CALL    JMP$INLNCOMP
  433.       DB    '600',0
  434.       RNC            ;go if got match
  435. ;
  436.       INX    B
  437.       CALL    JMP$INLNCOMP
  438.       DB    '1200',0
  439.       RNC            ;go if got match
  440. ;
  441.       INX    B
  442.       CALL    JMP$INLNCOMP
  443.       DB    '2400',0
  444.       RNC            ;go if got match
  445. ;
  446.       INX    B
  447.       CALL    JMP$INLNCOMP
  448.       DB    '4800',0
  449.       RNC            ;go if got match
  450. ;
  451.       INX    B
  452.       CALL    JMP$INLNCOMP
  453.       DB    '9600',0
  454.       RNC            ;go if got match
  455. ;
  456.       INX    B
  457.       CALL    JMP$INLNCOMP
  458.       DB    '19200',0
  459.       RNC            ;go if got match
  460. ;
  461.       MVI    B,0FFH        ;all matches failed
  462.       RET
  463. ;....
  464. ;
  465. ;
  466. ; Table of baudrate divisors
  467. ;
  468. ;
  469. ;
  470. BD110:      DW    1047
  471. BD300:      DW    384
  472. BD600:      DW    192    
  473. BD1200:      DW    96
  474. BD2400:   DW    48
  475. BD4800:   DW    24
  476. BD9600:      DW    12
  477. BD19200:  DW    6
  478. ;
  479. ;
  480. BAUDBUF:  DB    10,0
  481.       DS    10
  482. ;.......
  483. ;
  484. ;
  485. ; If using the Hayes Smartmodem this is unavailable without a special
  486. ; change.
  487. ;
  488. SPCLMENU:  RET
  489. ;
  490. ;
  491. ; NOTE:  MUST TERMINATE PRIOR TO 0400H (with Smartmodem)
  492. ;                 0C00H (without Smartmodem)
  493. ;.....
  494. ;
  495.       END
  496.