home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug121.arc / I2MD-1.ASM < prev    next >
Assembly Source File  |  1979-12-31  |  11KB  |  373 lines

  1.  
  2. ; I2MD-1.ASM - Morrow MD3 overlay for IMP - 08/05/85
  3. ;
  4. ;       USES 8251A I/O and 8254-2 baudrate generator
  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. ; This file adapts the Morrow MD3 to the IMP modem program.  This com-
  9. ; puter has two serial ports and one parallel (Centronics) printer port.
  10. ; It is for the MD3 with no internal dip switches.  The earlier models
  11. ; did not have a baudrate generator but had internal dip switches to se-
  12. ; lect various baud rates for the printer.
  13. ;
  14. ; Edit this file for your preferences then follow the "TO USE:" example
  15. ; shown below.
  16. ;
  17. ; Many terminals will clear the screen with a CTL-Z.  If yours does, put
  18. ; a 1AH at CLEAR: (010AH).  Many terminals use two characters, the first
  19. ; normally an ESC.  For example, ESC *.  In this case put '*' at CLEAR:
  20. ; (The ESC will automatically be typed with no CTL-character present.)
  21. ; If you don't know what your terminal uses, put a 0 at CLEAR: and IMP
  22. ; will scroll up 24 blank lines to clear the CRT for things like MENU,
  23. ; looking at the function key table, typing CTL-Z in command mode, etc.
  24. ;
  25. ; Use the "SET" command to change the baudrate when desired.  The value
  26. ; at MSPEED controls the baudrate when the program is first called up.
  27. ;
  28. ;    TO USE: First edit this file filling in answers for your own
  29. ;        equipment.  Then assemble with ASM.COM or equivalent
  30. ;        assembler.  Then use MLOAD to merge into the main file:
  31. ;
  32. ;        MLOAD IMP.COM=IMP.COM,I2MD-x.HEX
  33. ;
  34. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  35. ;
  36. ; 08/05/85 - Written to work with IMP        - Irv Hoff
  37. ;
  38. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  39. ;
  40. YES    EQU    0FFH
  41. NO    EQU    0
  42. ;
  43. ;
  44. ; Values shown are for a 8251A
  45. ;
  46. PORT    EQU    0FEH    ; Your base port (data or status)
  47. MDCTL1    EQU    PORT+1    ; Modem control port
  48. MDDATP    EQU    PORT    ; Modem data port
  49. MDRCV    EQU    02H    ; Modem receive ready
  50. MDSND    EQU    01H    ; Modem send ready bit
  51. MDTXE    EQU    05H    ; Modem send buffer empty, holding buffer empty
  52. ;
  53. COMMND    EQU    0F3H    ; Baudrate command port for control/status
  54. BRPORT    EQU    0F2H    ; Baudrate select port
  55. ;
  56. MDMODE    EQU    82H    ; Insures 8251 is out of mode with DTR high
  57. MDRSET    EQU    42H    ; Resets USART for additional commands
  58. MDSET1    EQU    4EH    ; 1 stop bit, no parity, 8 bits, x16
  59. MDSET2    EQU    0CEH    ; 2 stop bits, no parity, 8 bits, x16
  60. MDCOM    EQU    17H    ; Reset error flags, RCV, DTR, TX ready
  61. ;
  62. ;
  63. ;-----------------------------------------------------------------------
  64. ;
  65. ESC    EQU    '['-40H    ; ^[ = Escape
  66. BELL    EQU    'G'-40H    ; ^G = Bell character
  67. LF    EQU    'J'-40H    ; ^J = Linefeed
  68. NEXTRY    EQU    'K'-40H    ; ^K = Try next phone number, abort this try
  69. CR    EQU    'M'-40H    ; ^M = Carriage return
  70. CLEARSC    EQU    'Z'-40H    ; ^Z = Clears screen, command mode only
  71. EOFCHAR    EQU    'Z'-40H    ; ^Z = End of file
  72. ;
  73. ;
  74. ;-----------------------------------------------------------------------
  75. ;
  76. ;
  77.     ORG    0100H
  78. ;
  79. ;
  80.     DS    3        ; Skip the data area below
  81. ;
  82. ;
  83. ; These routines and equates are at the beginning of the program so
  84. ; they can be patched by a monitor or overlay file without re-assembling
  85. ; the program.
  86. ;
  87. MSPEED:     DB    6    ; 0=110 1=300 2=450 3=600 4=710 5=1200        103H
  88.             ; 6=2400 7=4800 8=9600 9=19200 default
  89. HS2400:     DB    NO    ; Yes=2400 bps highest speed            104H
  90. HS1200:     DB    yes    ; Yes=1200 bps highest speed            105H
  91. RACAL:     DB    NO    ; Yes=Racal-Vadic 1200V or 2400V or 2400PA    106H
  92. PROMODM: DB    NO    ; Yes=Prometheus ProModem 1200 bps        107H
  93. RESVD1:     DB    NO    ; Reserved for special modems            108H
  94. RESVD2:     DB    NO    ; Reserved for special modems            109H
  95. ;
  96. ;
  97. CLEAR:     DB    '*'    ; Clear screen character (ESC not needed)    10AH
  98. CLOCK:     DB    37    ; Clock speed in MHz x10, 25.5 MHz max.     10BH
  99.             ; 20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  100. BYTDLY:     DB    2    ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms        10CH
  101.             ;   default time to send character in ter-
  102.             ;   minal mode file transfer for slow BBS
  103. CRDLY:     DB    2    ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms    10DH
  104.             ;   default time for extra wait after CRLF
  105.             ;   in terminal mode file transfer
  106. NOFCOL:     DB    5    ; Number of directory columns shown        10EH
  107. TCHPUL:     DB    'T'    ; T=tone, P=Pulse (Hayes 2400 modems)        10FH
  108. ;.....
  109. ;
  110. ;
  111. ADDLFD:     DB    NO    ; Yes=add LF after CR to send file in terminal    110H
  112.             ;   mode (normally added by remote echo)
  113. CONVRUB: DB    YES    ; Yes=convert rub to backspace            111H
  114. CRCDFLT: DB    YES    ; Yes=default to CRC checking            112H
  115. IGNRCTL: DB    NO    ; Yes=CTL-chars above ^M not displayed        113H
  116. ;.....
  117. ;
  118. ;
  119. EXTCHR:     DB    '['-40H    ; ESC = preceeds local control character    114H
  120. EXITCHR: DB    'E'    ; Exit character                115H
  121. FILESND: DB    'F'    ; Send file when in terminal mode        116H
  122. NOCONCT: DB    'N'    ; Disconnect from phone line            117H
  123. LOGCHR:     DB    'L'    ; Send logon                    118H
  124. LSTCHR:     DB    'P'    ; Toggle printer                119H
  125. UNSAVCH: DB    'R'    ; Close input text buffer            11AH
  126. SAVECHR: DB    'Y'    ; Open input text buffer            11BH
  127. CLEARS:     DB    'Z'    ; Clears screen, terminal mode            11CH
  128. SPARE1:     DB    0    ; For future development            11DH
  129. SPARE2:     DB    0    ; For future development            11EH
  130. ;.....
  131. ;
  132. ;
  133. ; Handles in/out ports for data and status
  134. ;
  135. I$MDCTL1: IN    MDCTL1        ;                    11FH
  136.       RET            ; IN modem control port         121H
  137.       DB    0,0,0,0,0,0,0    ; Spares if needed            122H
  138. ;
  139. I$MDTXE:  IN    MDCTL1        ; (Needed for SIO or DART register 1    129H
  140.       RET            ;                    12BH
  141.       DB    0,0,0,0,0,0,0    ;                    12CH
  142. ;
  143. I$MDDATP: MVI    A,37H        ;                    133H
  144.       OUT    MDCTL1        ;                    135H
  145.       IN    MDDATP        ;                    137H
  146.       RET            ;                    139H
  147.       DB    0,0,0        ; Spares if needed            13AH
  148. ;
  149. O$MDDATP: OUT    MDDATP        ;                    13DH
  150.       RET            ; OUT modem data port            13FH
  151.       DB    0,0,0,0,0,0,0    ; Spares if needed            140H
  152. ;.....
  153. ;
  154. ;
  155. A$MDRCV:  ANI    MDRCV        ;                    147H
  156.       RET            ;                    149H
  157. ;
  158. C$MDRCV:  CPI    MDRCV        ;                    14AH
  159.       RET            ;                    14CH
  160. ;
  161. A$MDSND:  ANI    MDSND        ;                    14DH
  162.       RET            ;                    14FH
  163. ;
  164. C$MDSND:  CPI    MDSND        ;                    150H
  165.       RET            ;                    152H
  166. ;
  167. A$MDTXE:  ANI    MDTXE        ;                    153H
  168.       RET            ;                    155H
  169. ;
  170. C$MDTXE:  CPI    MDTXE        ;                    156H
  171.       RET            ;                    158H
  172. ;.....
  173. ;
  174. ;
  175. ; Special exit vector, used by some computers to reset interrupt vectors
  176. ;
  177. J$EXITVEC:RET            ;                    159H
  178.       DB    0,0        ;                    15AH
  179. ;.....
  180. ;
  181. ;
  182. ; Jump vectors needed by each overlay
  183. ;
  184. J$GOODBYE:JMP    GOODBYE        ; Disconnects modem by dropping DTR    15CH
  185. J$INITMOD:JMP    INITMOD        ; Initializes modem, autosets baudrate    15FH
  186. J$STUPR:  JMP    STUPR        ; SET routine to change baudrate    162H
  187. J$SYSVR:  JMP    SYSVR        ; Signon message            165H
  188. ;.....
  189. ;
  190. ;
  191. ; "AT" command strings, can be replaced in individual overlay if needed
  192. ;
  193. J$STRNGA: DS    3        ; 1200 bps "AT" string            168H
  194. J$STRNG1: DS    3        ; 2400 bps "AT" string            16B:IMP
  195. ;
  196. ;
  197. ; Next fourteen lines should not be changed by user overlay as these go
  198. ; to specific locations in the main program, not in the overlay.
  199. ;
  200. ;
  201. J$CMDSPL: DS    3        ; Allows entry of baudrate on CMD line    16EH
  202. J$CRLF:      DS    3        ; Turns up one new line on display    171H
  203. J$DIAL:      DS    3        ; Start of dialing routine        174H
  204. J$DSCONT: DS    3        ; Terminates modem use            177H
  205. J$GOLST:  DS    3        ; Printer routine, needed by Apple //e    17AH
  206. J$ILPRT:  DS    3        ; Prints an inline string, 0 to end    17DH
  207. J$INBUF:  DS    3        ; Stores a keybd string for comparison    180H
  208. J$INLNCP: DS    3        ; Inline "compare strings" routine    183H
  209. J$INMDM:  DS    3        ; Max .1 sec wait for modem character    186H
  210. J$RCVRSP: DS    3        ; For 3801 I/O use (TV-803)        189H
  211. J$SNDCHR: DS    3        ; Sends a character to the modem    18CH
  212. J$SNDSTR: DS    3        ; Sends a string to the modem, $ to end 18FH
  213. J$TIMER:  DS    3        ; .1 second timer (amount in 'B' reg.)    192H
  214. J$NEW1:      DB    0,0,0        ; For future needs            195H
  215. J$NEW2:      DB    0,0,0        ; For future needs            198H
  216. ;.....
  217. ;
  218. ;
  219. ; For 2400 bps auto-stepdown units
  220. ;
  221. MANUAL:      DB    0        ; For manual selection flag        19BH
  222. J$300:      JMP    OK300        ; Sets baudrate to 300 baud        19CH
  223. J$1200:      JMP    OK1200        ; Sets baudrate to 1200 bps        19FH
  224. J$2400:      JMP    OK2400        ; Sets baudrate to 2400 bps        1A2H
  225. ;.....
  226. ;
  227. ;
  228. LOGPTR:      DW    LOGON        ; Pointer to display LOGON message    1A5H
  229. ;
  230. SYSVR:      CALL    J$ILPRT        ; Display the following line        1A7H
  231.       DB    'Version for Morrow MD3 modem port 0FEH' ;        1AAH
  232.       DB    CR,LF,0
  233.       RET
  234. ;.....
  235. ;
  236. ;
  237. ;-----------------------------------------------------------------------
  238. ;
  239. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  240. ;     end of your last routine should terminate by 0400H (601 bytes
  241. ;     available after start of SYSVER).
  242. ;
  243. ;-----------------------------------------------------------------------
  244. ;
  245. ; You can put in a message at this location which can be called up with
  246. ; (special character-L).  You can put in several lines.  End with a 0.
  247. ;
  248. LOGON:    DB    'Hello from a happy Morrow MD3 owner...',CR,LF,0
  249. ;
  250. ;-----------------------------------------------------------------------
  251. ;
  252. ; This routine sets DTR low for one second to disonnect the phone
  253. ;
  254. GOODBYE:
  255.     MVI    B,'S'-40H    ; X-off to stop host if needed
  256.     CALL    J$SNDCHR
  257.     MVI    B,1        ; Wait a moment to let it react
  258.     CALL    J$TIMER
  259.     MVI    A,3DH        ; Send break, turn off DTR
  260.     OUT    MDCTL1        ; Send to status port
  261.     MVI    B,10        ; Delay 1 second to hang up phone
  262.     CALL    J$TIMER
  263.     MVI    A,37H        ; Normal send/receive with DTR
  264.     OUT    MDCTL1        ; Send to status port
  265.     RET
  266. ;.....
  267. ;
  268. ;
  269. ; Sets 8251 to 8 bits, DTR, RCV and TX ready
  270. ;
  271. INITMOD:
  272.     MVI    A,MDMODE    ; Insure 8251 is out of mode
  273.     OUT    MDCTL1
  274.     XTHL            ; Small delay to complete command
  275.     XTHL
  276.     MVI    A,MDRSET    ; Reset the 8251A for new command
  277.     OUT    MDCTL1
  278.     XTHL            ; Small delay to complete command
  279.     XTHL
  280.     MVI    A,MDSET1    ; Set stop pulse, no parity 8 bits, x16
  281.     OUT    MDCTL1
  282.     XTHL            ; Small delay to complete command
  283.     XTHL
  284.     MVI    A,MDCOM        ; Error reset, RCV, DTR, TX ready
  285.     OUT    MDCTL1
  286.     XTHL            ; Small delay to complete command
  287.     XTHL
  288. ;
  289.     LDA    MSPEED        ; Get the selected value
  290.     CPI    1        ; 300 bps
  291.     JZ    OK300
  292.     CPI    5        ; 1200 bps
  293.     JZ    OK1200
  294.     CPI    6        ; 2400 bps
  295.     JZ    OK2400
  296.     CPI    8        ; 9600 bps
  297.     JZ    OK9600
  298.     JMP    STUPR1        ; Else ask what is wanted
  299. ;.....
  300. ;
  301. ;
  302. ;
  303. STUPR:    CALL    J$CMDSPL    ; Gives us CMDBUF+6
  304.     JNC    STUPR2
  305. ;
  306. STUPR1:    CALL    J$ILPRT
  307.     DB    'Input Baud Rate (300, 1200, 2400, 9600): ',0
  308.     LXI    D,BAUDBUF    ; Point to new input buffer
  309.     CALL    J$INBUF
  310.     CALL    J$CRLF
  311.     LXI    D,BAUDBUF+2
  312. ;
  313. STUPR2:    CALL    J$INLNCP    ; Compare BAUDBUF+2 with chars. below
  314.     DB    '300',0
  315.     JNC    OK300        ; Go if got match
  316.     CALL    J$INLNCP
  317.     DB    '1200',0
  318.     JNC    OK1200
  319.     CALL    J$INLNCP
  320.     DB    '2400',0
  321.     JNC    OK2400
  322.     CALL    J$INLNCP
  323.     DB    '9600',0
  324.     JNC    OK9600
  325.     CALL    J$ILPRT        ; All matches failed, tell operator
  326.     DB    '++ Incorrect entry ++',CR,LF,BELL,CR,LF,0
  327.     JMP    STUPR1        ; Try again
  328. ;
  329. OK300:    MVI    A,1        ; MSPEED 300 baud value
  330.     LXI    H,BD300        ; Get 300 baud parameters in 'HL'
  331.     JMP    LOADBD        ; Go load them
  332. ;
  333. OK1200:    MVI    A,5
  334.     LXI    H,BD1200
  335.     JMP    LOADBD
  336. ;
  337. OK2400:    XRA    A
  338.     STA    MANUAL        ; Reset to maximum auto-speed
  339.     MVI    A,6
  340.     LXI    H,BD2400
  341.     JMP    LOADBD
  342. ;
  343. OK9600:    MVI    A,8
  344.     LXI    H,BD9600
  345. ;
  346. LOADBD:    STA    MSPEED        ; Change time-to-send to match baudrate
  347.     MVI    A,0BEH
  348.     OUT    COMMND        ; Baudrate generator command port
  349.     MOV    A,L        ; CTC command word
  350.     OUT    BRPORT
  351.     MOV    A,H        ; Get baudrate byte
  352.     OUT    BRPORT
  353.     RET
  354. ;.....
  355. ;
  356. ;
  357. ; Table of baudrate parameters
  358. ;
  359. BD300    EQU    417        ; 125100/300  converted to hex value
  360. BD1200    EQU    104        ; 125100/1200
  361. BD2400    EQU    52        ; 125100/2400
  362. BD9600    EQU    13        ; 125100/9600
  363. ;
  364. BAUDBUF:DB    10,0,0,0,0,0
  365.     DB    0,0,0,0,0,0
  366. ;
  367. ;                   end
  368. ;-----------------------------------------------------------------------
  369. ;
  370. ; NOTE: Must terminate by 0400H
  371. ;
  372.     END
  373.