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 / I2AS-2.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  11KB  |  378 lines

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