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 / IMP / I2MD-2.AZM / I2MD-2.ASM
Assembly Source File  |  2000-06-30  |  12KB  |  381 lines

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