home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol074 / h2651.asm < prev    next >
Encoding:
Assembly Source File  |  1984-04-29  |  9.5 KB  |  343 lines

  1. ;------------------------------------------------------------------------------
  2. ;
  3. ;    "HITE" Hardware Dependant Code Module for "2651" Family UARTS
  4. ;
  5. ;        Version 1.0 , March 10, 1982 - By Software Tools
  6. ;
  7. ;------------------------------------------------------------------------------
  8. ;
  9. ;    By    Bill Bolton
  10. ;        Software Tools,
  11. ;        P.O. Box 80,
  12. ;        Newport Beach,
  13. ;        NSW, 2106
  14. ;        AUSTRALIA
  15. ;
  16.     TITLE    '2651 UART Interface for HITE, Software Tools'
  17. ;DESCRIPTION:
  18. ;
  19. ;    This code is generally applicable to any 2561 based port. Conditional
  20. ;    assembly options are available for bank selected type ports such as
  21. ;    found on the Godbout Interfacer 3 IEEE-696 card. The code has been
  22. ;    extensively tested on both Godbout System Support and Interfacer 3
  23. ;    Cards. The code as presented here is set up for assembly with the
  24. ;    MAC or MACRO-80 assemblers. If you wish to assemble it with ASM the
  25. ;    'TITLE' line must be removed and the 'hexnum' macro must be eliminated
  26. ;    and the port numbers in the signon message must be expanded by hand
  27. ;    (i.e. you'll have to plug the ASCII values for the port addresses
  28. ;    into the message yourself).
  29. ;
  30. ;    See the additional notes near the INIT, EXIT and HEXNUM routines.
  31. ;
  32. ;************************************************
  33. ;*                        *
  34. ;*         Miscellaneous Equates        *
  35. ;*                        *
  36. ;************************************************
  37. ;
  38. TRUE    EQU    0FFFFH
  39. FALSE    EQU    NOT TRUE
  40.  
  41. BDOS    EQU    0005            ;CP/M BDOS entry point
  42. ALF    EQU    0AH            ;ASCII line feed
  43. ACR    EQU    0DH            ;ASCII carriage return
  44. ;
  45. ;************************************************
  46. ;*                        *
  47. ;*         2651 Baud Rate Table        *
  48. ;*                        *
  49. ;************************************************
  50. ;
  51. B50    EQU    0000B            ;50 bps
  52. B75    EQU    0001B            ;75 bps
  53. B110    EQU    0010B            ;110 bps
  54. B134    EQU    0011B            ;134.5 bps
  55. B150    EQU    0100B            ;150 bps
  56. B300    EQU    0101B            ;300 bps
  57. B600    EQU    0110B            ;600 bps
  58. B1200    EQU    0111B            ;1200 bps
  59. B1800    EQU    1000B            ;1800 bps
  60. B2000    EQU    1001B            ;2000 bps
  61. B2400    EQU    1010B            ;2400 bps
  62. B3600    EQU    1011B            ;3600 bps
  63. B4800    EQU    1100B            ;4800 bps
  64. B7200    EQU    1101B            ;7200 bps
  65. B9600    EQU    1110B            ;9600 bps
  66. B19200    EQU    1111B            ;19200 bps
  67. ;
  68. ;************************************************
  69. ;*                        *
  70. ;*        2651 Equates            *
  71. ;*                        *
  72. ;************************************************
  73. ;
  74. BASE    EQU    5CH            ;UART base register
  75. DATA    EQU    BASE+0            ;Data port
  76. STATUS    EQU    BASE+1            ;Status port
  77. MODE    EQU    BASE+2            ;Mode register
  78. CMMD    EQU    BASE+3            ;Command register
  79. USER    EQU    BASE+7            ;User select port
  80. UNUM    EQU    6            ;Modem user number
  81. MODE1    EQU    01101110B        ;Asynch,16x,8 data bits,
  82.                     ; no parity, even, 1 stop bit
  83. MODE2    EQU    01110000B + B300    ;Baud rate
  84. CMMDB    EQU    00100111B        ;Tx enabled, RX enabled, no break
  85.                     ; DTR high, RTS high
  86. ERESET    EQU    CMMDB+8            ;Error reset
  87. ;
  88. SYSSPT    EQU    TRUE            ;True for Godbout system support
  89. INTER3    EQU    NOT SYSSPT        ;True for Godbout Interfacer 3
  90. ;
  91. ;
  92. ;------------------------------------------------------------------------------
  93. ;
  94.         ORG    108H
  95. SDRIVE:
  96.     DB    0        ;SET NON-ZERO FOR SINGLE DRIVE SITE.
  97. BEEP:
  98.     DB    0        ;SET NON-ZERO TO BEEP WHEN DONE.
  99. TIMEOUT:
  100.     DB    6        ;COUNT-DOWN VALUE FOR TIMEOUT (ABOUT 30 SECS.)
  101.                 ;WITH A 4MHZ Z80, 1 = 5 SEC. (SORT OF).
  102.                 ;    HENCE ZERO = 21.25 MINUTES.
  103.                 ;THE SELECTED VALUE IS A TRADE-OFF, SINCE A LOW
  104.                 ;VALUE MAY TIME-OUT WHILE THE RECEIVER IS
  105.                 ;WRITING TO DISC (WHICH DOES NO HARM BUT CLOGGS
  106.                 ;UP THE SCREEN WITH DISPLAYS) AND A HIGH VALUE
  107.                 ;CAUSES THE KEYBOARD TH BE CHECKED LESS OFTEN.
  108.                 ;
  109. ;------------------------------------------------------------------------------
  110. ;
  111. ;
  112. HINIT:        JMP    INIT        ;UART/USART INITIALATION ENTRY POINT
  113. HEXIT:        JMP    EXIT        ;SPECIAL USER EXIT ROUTINE
  114. HSTAT:        JMP    STAT        ;STATUS PORT READ ENTRY POINT
  115. HRES:        JMP    RES        ;UART/USART ERROR RESET ENTRY POINT
  116. HRX:        JMP    RX        ;READ DATA PORT ENTRY POINT
  117. HTX:        JMP    TX        ;WRITE DATA PORT ENTRY POINT
  118. ;
  119. ;
  120. ;------------------------------------------------------------------------------
  121. ;            THIS IS THE UART/USART INITIALISATION ROUTINE.
  122. ;            TO ENSURE COMPATIBILITY WITH OTHER USERS, THE
  123. ;            FOLLOWING STANDARD IS RECCOMENDED :
  124. ;            1. USE 1 STOP BIT    (OPTIONAL - 2)
  125. ;            2. USE 8 DATA BITS    (MANDATORY)
  126. ;            3. USE 1 START BIT    (MANDATORY)
  127. ;            4. USE ASYNC MODE ONLY    (MANDATORY)
  128. ;
  129. ;            For the 2651, the UART operating parameters
  130. ;            (which are under software control) are read and stored.
  131. ;            On exit from HITE these    entry paramters will be
  132. ;            restored to the UART. This allows HITE to
  133. ;            transparently use different UART parameters from
  134. ;            other programs that may utilise the port.
  135. ;
  136. INIT:
  137.  
  138.     if    inter3
  139.     MVI    A,UNUM
  140.     OUT    USER        ;Select UART
  141.     endif    ;inter3
  142.  
  143.     IN    MODE        ;Get first mode byte from entry format
  144.     STA    SMODE1        ;Save for exit
  145.     IN    MODE        ;Get second mode byte
  146.     STA    SMODE2        ;Save for exit
  147.     IN    CMMD        ;Get command byte
  148.     STA    SCMMDB        ;Save for exit
  149. INIT1:
  150.     MVI    A,MODE1        ;Put first mode word for HITE format
  151.     OUT    MODE
  152.     MVI    A,MODE2        ;Put second mode word
  153.     OUT    MODE
  154.     MVI    A,CMMDB        ;Put command byte
  155.     OUT    CMMD
  156. SIGNON:
  157.     LXI    D,MESSGE    ;Message is at the end of this module
  158.     MVI    C,9        ;BDOS display string command
  159.     JMP    BDOS        ;Announce version to user and return
  160.                 ;to HITE via BDOS RET instruction
  161. ;
  162. SMODE1    DB    0        ;Storage for first entry mode byte
  163. SMODE2    DB    0        ;Storage for second entry mode word
  164. SCMMDB    DB    0        ;Storage for entry command byte
  165. ;
  166. ;------------------------------------------------------------------------------
  167. ;            THIS SECTION IS INCLUDED FOR ANY "SPECIAL" USER
  168. ;            EXIT CODE. (EG. RESTORING INTERRUPT VECTORS).
  169. ;            IF UNUSED, A <RETURN> IS THE ONLY CODE NEEDED.
  170. ;            AS THIS IS THE LAST ROUTINE OBEYED BEFORE THE TEST
  171. ;            FOR "SINGLE DRIVE SITES" IS MADE, NO REGISTERS NEED
  172. ;            TO BE PRESERVED.
  173. ;
  174. ;
  175. ;            For the 2651, the UART operating parameters
  176. ;            (entry parameters) will be restored to the UART.
  177. ;            This allows HITE to transparently use different
  178. ;            UART parameters from other programs that may utilise
  179. ;            the port. This is particularly     handy if the same
  180. ;            port has to double for another function such as a
  181. ;            printer port etc. It is also useful if a dedicated
  182. ;            communications port must use different parameters
  183. ;            (i.e number of stop bits) when communicating with
  184. ;            a variety of other computers in text or binary
  185. ;            modes. 
  186. ;
  187. EXIT:
  188.     LDA    SMODE1        ;Get first mode byte of entry format
  189.     OUT    MODE
  190.     LDA    SMODE2        ;Get second mode byte of entry format
  191.     OUT    MODE
  192.     LDA    SCMMDB        ;Get command byte of entry format
  193.     JMP    RES        ;Do an error reset
  194. ;
  195. ;
  196. ;------------------------------------------------------------------------------
  197. ;            THIS IS THE STATUS READ PORT ROUTINE.
  198. ;            IT MUST EMULATE THE STATUS BITS FOR
  199. ;            AN 8251 USART. I.E.
  200. ;
  201. ;            BIT 00 SET IF TRANSMITTER READY
  202. ;            BIT 01 SET IF RECEIVER READY
  203. ;            BIT 02 SET IF TRANSMITTER EMPTY
  204. ;            BIT 03 SET IF PARITY  ERROR
  205. ;            BIT 04 SET IF OVERRUN ERROR
  206. ;            BIT 05 SET IF FRAMING ERROR
  207. ;            BITS 06 AND 07 RESET (I.E. 0)
  208. ;
  209. ;    *** NOTE: ONLY THE "A" REGISTER SHOULD BE ALTERED. ***
  210. ;
  211. ;
  212. STAT:
  213.     if    inter3
  214.     MVI    A,UNUM
  215.     OUT    USER        ;Select UART
  216.     endif    ;inter3
  217.  
  218.     IN    STATUS        ;Get status
  219.     ORI    4        ;Force Tx empty high
  220.     RET
  221. ;
  222. ;
  223. ;------------------------------------------------------------------------------
  224. ;            THIS IS THE ERROR RESET FOR UART/USART ROUTINE.
  225. ;            IF YOUR UART/USART DOES NOT NEED TO BE RESET ON
  226. ;            ERROR, WE RECCOMEND THAT YOU DO AN "IN DATA" TO
  227. ;            CLEAR THE AIR AND RETURN.
  228. ;
  229. RES:
  230.     if    inter3
  231.     MVI    A,UNUM
  232.     OUT    USER        ;Select UART
  233.     endif    ;inter3
  234.  
  235.     MVI    A,ERESET    ;Reset error flags in 2651
  236.     OUT    CMMD
  237.     MVI    A,CMMDB        ;Restore normal operation
  238.     OUT    CMMD
  239.     RET
  240. ;
  241. ;
  242. ;------------------------------------------------------------------------------
  243. ;            THIS IS THE RECEIVE DATA ROUTINE.
  244. ;            BEFORE THIS ROUTINE IS ENTERED BIT 02 OF THE
  245. ;            STATUS READ ROUTINE MUST HAVE BEEN SET.
  246. ;            DO NOT CLEAR THE TOP (MOST SIGNIFICANT) BIT.
  247. ;            RETURN WITH REGISTER A LOADED WITH INPUT DATA.
  248. ;
  249. ;
  250. ;
  251. RX:
  252.     if    inter3
  253.     MVI    A,UNUM
  254.     OUT    USER        ;Select UART
  255.     endif    ;inter3
  256.  
  257.     IN    DATA        ;Get data
  258.     RET
  259. ;
  260. ;
  261. ;
  262. ;------------------------------------------------------------------------------
  263. ;            THIS IS THE TRANSMIT DATA ROUTINE.
  264. ;            BEFORE THIS ROUTINE IS ENTERED BIT 00
  265. ;            AND  BIT 3 OF STATUS READ MUST BE SET.
  266. ;            DO NOT CLEAR THE TOP BIT BEFORE OUUDATUT.
  267. ;            REGISTER A CONTAINS THE DATA.
  268. ;
  269. TX:
  270.     if    inter3
  271.     PUSH    PSW
  272.     MVI    A,UNUM
  273.     OUT    USER        ;Select UART
  274.     POP    PSW
  275.     endif    ;inter3
  276.  
  277.     OUT    DATA        ;Send data
  278.     RET
  279. ;
  280. ;
  281. ;
  282. ;------------------------------------------------------------------------------
  283. ;
  284. ;            THE PURPOSE OF THIS MEASSGE IS TO SHOW
  285. ;            (OR REMIND) YOU OF THE ACTUAL HARDWARE
  286. ;            THAT THIS VERSION OF HITE IS SET UP FOR.
  287. ;
  288. ;            Note that only one level of the stack
  289. ;            is used on entry to the initialisation routine.
  290. ;            The rest of the "reserved" stack space
  291. ;            may be used for the signon message as this is only
  292. ;            needed once near the start of HITE. Once the message
  293. ;            has been displayed it can be safely overwritten by
  294. ;            the stack.
  295. ;
  296. ;
  297. HEXNUM    macro    num
  298.     if    (num/16) > 9     
  299.     db    (num/16 and 0fh) + 'A' - 10
  300.     else
  301.     db    (num/16 and 0fh) + '0'
  302.     endif
  303.     if    (num and 0fh) > 9
  304.     db    (num and 0fh) + 'A' - 10
  305.     else
  306.     db    (num and 0fh) + '0'
  307.     endif
  308.     endm
  309.  
  310. MESSGE:    DB    ACR,ALF,ALF
  311.     DB    'For 2651 UART'
  312.  
  313.     if    sysspt
  314.     DB    ' on System Support 1 Board'
  315.     endif    ;sysspt
  316.  
  317.     if    inter3
  318.     DB    ' on Interfacer 3 Board'
  319.     endif    ;sysspt
  320.  
  321.     DB    ',',ACR,ALF
  322.     DB    'at port ' 
  323.     hexnum    %BASE
  324.     DB    'H, 300 bps, 1 stop, no parity.',ACR,ALF
  325.  
  326.     if    inter3
  327.     DB    'UART Offset '
  328.     hexnum    %UNUM
  329.     DB    ', '
  330.     endif    ;inter3
  331.  
  332.     DB    'Version 1.0, 10/May/82',ACR,ALF
  333.     DB    '$'
  334. ;
  335. ;
  336. ;
  337. ;
  338. ;------------------------------------------------------------------------------
  339. ;
  340. ;
  341.     END
  342.