From 7e9f18b2d240ecef6d0c85f5b8ab3a28342b493f Mon Sep 17 00:00:00 2001 From: Gale Faraday Date: Thu, 11 Sep 2025 18:11:42 -0500 Subject: [PATCH] fix(serial): fixed loop logic in POUTZSTR and some formatting --- src/serial.s | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/serial.s b/src/serial.s index 7107965..c2dd6ea 100644 --- a/src/serial.s +++ b/src/serial.s @@ -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