4 Commits

Author SHA1 Message Date
9edc255412 style: caps in comment fix 2024-12-11 05:30:33 -06:00
971dc1d719 feat: new serial functions 2024-12-07 10:30:15 -06:00
1237cc89eb chore: using aliases from hardware.inc and optimized divisor setup 2024-12-07 06:55:22 -06:00
Amber
808f868344 Merge pull request #12 from amberisvibin/hardware.inc
Setup hardware.inc
2024-12-05 20:59:14 -05:00

View File

@@ -10,37 +10,71 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SECTION "Reset"
ORG ROM_BASE ORG ROM_BASE
RESET RESET
lda #%11000001 ; 8n1 serial, enable DLAB ; 8n1 Serial Enable DLAB
lda #(UARTF_LCR_WLS | UARTF_LCR_DLAB)
sta UART_LCR sta UART_LCR
lda #$00 ; Set divisor to 12 (9600 baud) ; REVIEW: Potential endianness hiccough here
sta UART_DLL ldd #$0C00 ; Set divisor to 12 (9600 baud)
lda #$0C
sta UART_DLM sta UART_DLM
stb UART_DLL
lda #%11000000 ; 8n1 serial, disable DLAB lda #(UARTF_LCR_WLS) ; 8n1 serial, disable DLAB
sta UART_LCR sta UART_LCR
lda #%01000000 ; Enable RTS lda #(UARTF_MCR_RTS) ; Enable Request-to-Send
sta UART_MCR sta UART_MCR
lda 'H ; send 'H' lda 'H ; send 'H'
sta UART_BUFR sta UART_BUFR
WAIT WAIT
sync ; Wait for interrupts sync ; Wait for interrupts
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