Advertisement
Guest User

echo.z80

a guest
May 20th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;***************************************************************************
  2. ;  PROGRAM:         UART  Echo Test Program        
  3. ;  PURPOSE:         Key typed on PC will display  
  4. ;  ASSEMBLER:       TASM 3.2        
  5. ;  LICENCE:         The MIT Licence
  6. ;  AUTHOR :         MCook
  7. ;  CREATE DATE :    15 Mar 15
  8. ;***************************************************************************
  9.  
  10. UART0:       .EQU    00H            ; DATA IN/OUT
  11. UART1:       .EQU    01H            ; CHECK RX
  12. UART2:       .EQU    02H            ; INTERRUPTS
  13. UART3:       .EQU    03H            ; LINE CONTROL
  14. UART4:       .EQU    04H            ; MODEM CONTROL
  15. UART5:       .EQU    05H            ; LINE STATUS
  16. UART6:       .EQU    06H            ; MODEM STATUS
  17. UART7:       .EQU    07H            ; SCRATCH REG.
  18.  
  19. .ORG 00H
  20.  
  21. ;***************************************************************************
  22. ;INIT_UART
  23. ;Function: Initialize the UART to BAUD Rate 9600 (1.8432 MHz clock input)
  24. ;DLAB A2 A1 A0 Register
  25. ;0    0  0  0  Receiver Buffer (read),
  26. ;              Transmitter Holding
  27. ;              Register (write)
  28. ;0    0  0  1  Interrupt Enable
  29. ;X    0  1  0  Interrupt Identification (read)
  30. ;X    0  1  0  FIFO Control (write)
  31. ;X    0  1  1  Line Control
  32. ;X    1  0  0  MODEM Control
  33. ;X    1  0  1  Line Status
  34. ;X    1  1  0  MODEM Status
  35. ;X    1  1  1  Scratch
  36. ;1    0  0  0  Divisor Latch
  37. ;              (least significant byte)
  38. ;1    0  0  1  Divisor Latch
  39. ;              (most significant byte)
  40. ;***************************************************************************
  41.  
  42. INIT_UART:
  43.             LD     A,80H            ; Mask to Set DLAB Flag
  44.             OUT    (UART3),A
  45.             LD     A,12             ; Divisor = 12 @ 9600bps w/ 1.8432 Mhz
  46.             OUT    (UART0),A        ; Set BAUD rate to 9600
  47.             LD     A,00
  48.             OUT    (UART1),A        ; Set BAUD rate to 9600
  49.             LD     A,03H
  50.             OUT    (UART3),A        ; Set 8-bit data, 1 stop bit, reset DLAB Flag
  51.            
  52.            
  53. MAIN:
  54.             LD      A,00H      
  55.            
  56. ;***************************************************************************
  57. ;GET_CHAR_UART
  58. ;Function: Get current character from UART place in Accumulator
  59. ;***************************************************************************
  60.  
  61. GET_CHAR_UART:  
  62.             IN      A,(UART5)       ; Get the line status register's contents
  63.             BIT     0,A             ; Test BIT 0, it will be set if the UART is ready to receive
  64.             JP      Z,GET_CHAR_UART
  65.            
  66.             IN      A,(UART0)       ; Get character from the UART
  67.             LD      B,A             ; Store character into B Register
  68.            
  69. ;***************************************************************************
  70. ;SEND_CHAR_UART
  71. ;Function: Send current character in Accumulator to UART
  72. ;***************************************************************************
  73.  
  74. SEND_CHAR_UART:  
  75.             IN      A,(UART5)       ; Get the line status register's contents
  76.             BIT     5,A             ; Test BIT 5, it will be set if the UART is ready to send
  77.             JP      Z,SEND_CHAR_UART
  78.            
  79.             LD      A,B             ; Get character from B Register obtained earlier
  80.             OUT     (UART0),A       ; Send character through the UART
  81.            
  82.     JP      MAIN
  83.            
  84. .END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement