forked from dhansel/smon6502
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuart_ria816.asm
32 lines (27 loc) · 1.23 KB
/
uart_ria816.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
;;; ----------------------------------------------------------------------------
;;; ---------------------- UART communication functions -----------------------
;;; ----------------------------------------------------------------------------
UART = $FFE0
UARTS = UART+0
UARTD = UART+1
;; initialize UART
UAINIT: rts ; no need to reset anything
;; write character to UART, wait until UART is ready to transmit
;; A, X and Y registers must remain unchanged
UAPUTW: BIT UARTS ; check UART status
BPL UAPUTW ; wait if cannot write (bit 7)
STA UARTD ; write character
RTS
;; get character from UART, return result in A,
;; return A=0 if no character available for reading
;; X and Y registers must remain unchanged
UAGET: LDA UARTS ; check UART status
AND #$40 ; can read?
BEQ UAGRET ; if not, return with Z flag set
LDA UARTD ; read UART data
UAGRET: RTS
;; get character from UART, wait if none, return result in A
;; X and Y registers must remain unchanged
UAGETW: JSR UAGET
BEQ UAGETW
RTS