fix(serial): fixed loop logic in POUTZSTR and some formatting

This commit is contained in:
2025-09-11 18:11:42 -05:00
parent fbb94b8707
commit 7e9f18b2d2

View File

@@ -20,13 +20,13 @@
; ACCA: Index of the divsor to use in DIVISORS
; ACCB: Settings for LCR
INITUART
pshs b ; Preserve LCR while we set up divisors
ldx #DIVISORS ; Get DIVISORS base addr
asla ; Shift left to *2 the index in order to iter over words.
pshs b ; Save B
ldd a,x ; Get divisor into D
sta UART_DLM ; Write divisor MSB
stb UART_DLL ; Write divisor LSB
puls b ; Restore B
puls b
stb UART_LCR ; Write LCR
lda UARTF_FCR_FE|UARTF_FCR_RFR|UARTF_FCR_XFR ; FIFO disable and clear
sta UART_FCR
@@ -39,10 +39,10 @@ INITUART
; ACCA: char to write
POUTCHAR
pshs a ; Preserve char
NEXTC@
NOTREADY@
lda UART_LSR ; Wait until LSR.THRE == 1 then write char
bita UARTF_LSR_THRE
beq NEXTC@
beq NOTREADY@
puls a ; Restore char
sta UART_THR ; Write char
rts
@@ -54,19 +54,19 @@ POUTZSTR
NEXTC@
ldb 0,x ; Get next char from X
cmpb #$00 ; Make sure that we aren't at a terminator
leax 1,x ; Increment X for next char. we inc here to save bytes if the
; next string is adjacent.
beq END@
NOTREADY@
lda UART_LSR ; Wait until LSR.THRE == 1 then write char
bita UARTF_LSR_THRE
beq NOTREADY@
stb UART_THR ; Write char
leax 1,x ; Iter to next char. We X++ here because leax modifies CC.Z
bra NEXTC@ ; Iter to next char
END@
puls b,a ; Restore A and B
rts
; UART baud rate divisors
DIVISORS
fdb $0900 ; 50 baud
fdb $0600 ; 75 baud