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 / GENASM / ZSIOINIT.AQM / ZSIOINIT.ASM
Assembly Source File  |  2000-06-30  |  5KB  |  220 lines

  1. ;    Initialization program for Televideo 801/802
  2. ;            written by Les Freed
  3. ;            Version 1.0 3/17/82
  4. ;
  5. ;07/25/82 Corrected error which had SIO initialization code going to data port
  6. ;      rather than status/control port and inserted code using Z80 block
  7. ;      output instruction from a program I had written previously. Actually
  8. ;      the Televideo seems to initialize the SIO somewhere in the system
  9. ;      software and for the most part only needs the CTC initialized to set
  10. ;      the baud rate, which is why this program worked before. (Bob Clyne)
  11. ;
  12. bdos    equ    5        ;CP/M entry point
  13. ;
  14. udta    equ    20h        ;usart data port
  15. usta    equ    22h        ;usart status port
  16. ;
  17. cr    equ    0dh        ;carriage return
  18. lf    equ    0ah        ;line feed
  19. ;
  20.     org    100h
  21. ;
  22. start:    lxi    d,signon    ;print table
  23.     call    print
  24. ;
  25.     lxi    d,msg1        ;print message
  26.     call    print
  27. i1:    call    input        ;get input
  28.     call    check        ;check range
  29.     jc    i1        ;try again if carry set
  30.     sui    30h        ;remove ASCii bias
  31.     sta    baud        ;store divisor
  32. ;
  33. show:    lxi    d,clear        ; clear screen
  34.     call    print
  35.     lxi    d,msg1        ;print 'baud rate:'
  36.     call    print
  37.     lda    baud        ;get a's divisor
  38.     call    prbaud        ;print a's baud rate
  39.     lxi    d,crmsg        ;ask user if okay
  40.     call    print
  41.     call    input
  42.     cpi    cr
  43.     jnz    start        ;if not CR, then start over
  44. ;
  45.  
  46. ;             SIO-INIT.ASM
  47. ;              Version 02
  48. ;         Originally written by Bob Clyne
  49. ;              November 22, 1981
  50. ;
  51. ;This code initializes a Z80-SIO or Z80-DART IC for asynchronous communication.
  52. ;It uses Z80 instructions and therefore will only run on a Z80 CPU. This
  53. ;program can be run prior to using the I/O port or this code may be transferred
  54. ;to the initialization section of another program such as one of the MODEM
  55. ;programs. The status/control port number will need to be set for each
  56. ;application.
  57. ;
  58. ;01/21/82 Changed introduction and added equates for XEROX 820 Channel A.
  59. ;
  60. FALSE    EQU    0
  61. TRUE    EQU    NOT FALSE
  62. ;
  63. ;Only one of the following equates should be set true.
  64. ;
  65. XEROX    EQU    FALSE
  66. ALTOS    EQU    FALSE
  67. TELEVID    EQU    TRUE    ;Added 07/25/82
  68. ;
  69.     IF    ALTOS    ;ALTOS 2nd printer port
  70. DPORT    EQU    28H    ;DATA PORT (Included for information only, not used.)
  71. CTRLPT    EQU    29H    ;Status/control port.
  72.     ENDIF
  73. ;
  74.     IF    XEROX    ;XEROX 820 Channel A serial port.
  75. CTRLPT    EQU    06H    ;Status/control port.
  76.     ENDIF
  77. ;
  78.     IF TELEVID
  79. CTRLPT    EQU    usta    ;Use port equate from begining of pgm. (RAC 07/25/82)
  80.     ENDIF
  81. ;
  82. ;    MACLIB    Z80    ;To assemble using ASM comment out this line and make
  83.             ;the change noted below.
  84. ;
  85. ;    ORG    100H
  86. ;
  87.  
  88. SIO:    MVI    B,07H    ;NUMBER OF BYTES NEEDED TO INITIALIZE THE SERIAL PORT
  89.     MVI    C,CTRLPT;PORT TO SEND INITIALIZATION BYTES TO
  90.     LXI    H,INITBL;ADDRESS OF TABLE OF BYTES TO SEND
  91. ;    OUTIR        ;OUTPUT THE BLOCK
  92.     DB    0EDH,0B3H;To assemble on ASM, comment out the above instruction
  93.              ;and remove the ';' from in front of 'DB'
  94. ;    RET        ;RETURN TO CPM
  95.     JMP    CTC    ;Jump to old code to set the CTC (RAC 07/25/82)
  96. ;
  97. INITBL:    DB    18H    ;CHANNEL RESET
  98.     DB    04H    ;WRITE REGISTER 4
  99.     DB    44H    ;SET X16 CLOCK, 1 STOP BIT, NO PARITY
  100.     DB    05H    ;WRITE REGISTER 5
  101.     DB    0EAH    ;SET DTR & RTS ACTIVE & ENABLE 8 BIT TRANSMIT
  102.     DB    03H    ;WRITE REGISTER 3
  103.     DB    0E1H    ;ENABLE 8 BIT RECEIVE & AUTO ENABLES
  104. ;    DB    0C1H    ;Enable 8 bit receive without AUTO ENABLES.
  105.             ;Comment out whichever of the above 2 lines you don't
  106.             ;... want.
  107.  
  108. ;    END
  109. ;
  110. CTC:    mvi    a,47h        ; counter mode follows (Lable added RAC)
  111.     out    08h        ; send
  112.     lda    baud        ; get baud rate divisor
  113.     out    08h        ; send to port
  114. ;
  115.     lxi    d,msg        ;tell user we're done
  116.     call    print
  117.     ret            ;& return to CP/M    
  118. ;
  119. print:    mvi    c,9        ;CP/M print string call
  120.     call    bdos
  121.     ret
  122. ;
  123. input:    mvi    c,1        ;CP/M get char. call
  124.     call    bdos
  125.     ret
  126. ;
  127. check:    cpi    30h        ;at least '0'
  128.     jc    notok
  129.     cpi    37h        ;& not >'6'
  130.     jnc    notok
  131.     stc            ;reset carry
  132.     cmc
  133.     ret
  134. ;
  135. notok:    lxi    d,badmsg    ;print message, move back up screen
  136.     call    print
  137.     stc ! ret        ;return w/ carry set
  138. ;
  139. prbaud:    cpi    0        ;find divisor, convert & print baud rate 
  140.     jnz    pr1
  141.     lxi    d,m19
  142.     mvi    a,2
  143.     jmp    pr8
  144. ;
  145. pr1:    cpi    1
  146.     jnz    pr2
  147.     lxi    d,m96
  148.     mvi    a,4
  149.     jmp    pr8
  150. ;
  151. pr2:    cpi    2
  152.     jnz    pr3
  153.     lxi    d,m48
  154.     mvi    a,8
  155.     jmp    pr8
  156. ;
  157. pr3:    cpi    3
  158.      jnz    pr4
  159.     lxi    d,m24
  160.     mvi    a,10h
  161.     jmp    pr8
  162. ;
  163. pr4:    cpi    4
  164.     jnz    pr5
  165.     lxi    d,m12
  166.     mvi    a,20h
  167.     jmp    pr8
  168. ;
  169. pr5:    cpi    5
  170.     jnz    pr6
  171.     lxi    d,m6
  172.     mvi    a,40h
  173.     jmp    pr8
  174. ;
  175. pr6:    cpi    6
  176.     jnz    pr8
  177.     lxi    d,m3
  178.     mvi    a,80h
  179. ;
  180. pr8:    sta    baud
  181.     jmp    print
  182. ;
  183.  
  184. ;
  185. signon:    db    1ah,'INIT v 1.0      3-18-82',cr,lf,lf,lf
  186.     db    'Select Baud Rate: ',cr,lf,lf
  187. ;
  188.     db    'Speed',cr,lf
  189.     db    '19200 0',cr,lf
  190.     db    ' 9600 1',cr,lf
  191.     db    ' 4800 2',cr,lf
  192.     db    ' 2400 3',cr,lf
  193.     db    ' 1200 4',cr,lf
  194.     db    '  600 5',cr,lf
  195.     db    '  300 6',cr,lf
  196.     db    lf,lf,lf,'$'
  197. ;
  198. m19:    db    '  19200$'
  199. m96:    db    '   9600$'
  200. m48:    db    '   4800$'
  201. m24:    db    '   2400$'
  202. m12:    db    '   1200$'
  203. m6:    db    '    600$'
  204. m3:    db    '    300$'
  205. ;
  206. badmsg:    db    cr,lf,7,'Re-enter',cr
  207.     db    11,12,12,12,12,12,12
  208.     db    12,12,12,12,12,'$'    ;move cursor back to entry
  209. ;
  210. clear:    db    1ah,'$'
  211. ;
  212. crmsg:    db    cr,lf,lf,lf,lf,'Press RETURN to set baud rate :','$'
  213. ;
  214. msg:    db    cr,lf,'Port initialized',0dh,0ah,'$'
  215. msg1:    db    cr,lf,'Baud rate :$'
  216. ;
  217. baud    ds    1
  218. ;
  219.     end
  220.