feat: new serial functions
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
;;
|
;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
SECTION "Reset"
|
||||||
ORG ROM_BASE
|
ORG ROM_BASE
|
||||||
|
|
||||||
RESET
|
RESET
|
||||||
@@ -36,12 +37,44 @@ WAIT
|
|||||||
nop
|
nop
|
||||||
bra WAIT
|
bra WAIT
|
||||||
|
|
||||||
|
SECTION "Serial"
|
||||||
|
|
||||||
|
; Writes a char to the UART in non FIFO mode, preserves A.
|
||||||
|
; @param b: char to write
|
||||||
|
OUTCHAR
|
||||||
|
pshs a ; Preserve A
|
||||||
|
1
|
||||||
|
lda UART_LSR ; if LSR.THRE == 1 then write
|
||||||
|
anda UARTF_LSR_THRE
|
||||||
|
bne 1B ; Loop if UART not ready yet
|
||||||
|
stb UART_BUFR ; Write char
|
||||||
|
puls a ; Restore A
|
||||||
|
rts
|
||||||
|
|
||||||
|
; Writes a null terminated string to the UART in non FIFO mode, clobbers A and
|
||||||
|
; B.
|
||||||
|
; @param x: null terminated string start address.
|
||||||
|
OUTSTR
|
||||||
|
ldb x ; Get the next value from X
|
||||||
|
cmpb #$00 ; Make sure that mother is non-null
|
||||||
|
beq 2F
|
||||||
|
leax 1,x ; Increment X for our next char
|
||||||
|
1 ; Loop point for UART waiting
|
||||||
|
lda UART_LSR ; Wait for UART to be ready
|
||||||
|
anda UARTF_LSR_THRE
|
||||||
|
bne 1B
|
||||||
|
stb UART_BUFR ; Actually do our write
|
||||||
|
bra OUTSTR ; Reset for the next char
|
||||||
|
2 ; Jump point for End of routine
|
||||||
|
rts
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;
|
;;
|
||||||
;; Interrupt and Reset Vectors
|
;; Interrupt and Reset Vectors
|
||||||
;;
|
;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
SECTION "Vectors"
|
||||||
ORG VECS_BASE
|
ORG VECS_BASE
|
||||||
|
|
||||||
VECTORS
|
VECTORS
|
||||||
|
Reference in New Issue
Block a user