Commit 0518fa06 authored by Koen Martens's avatar Koen Martens
Browse files

gios: initialize uart, flush uart

parent 0125b5b2
......@@ -9,10 +9,21 @@ loop:
jzre done
jre loop
done:
.ldsrc greeting
.lddst uart_send_string
.lddst uart_init ; initialize uart
puship
jmpdst
.ldsrc greeting ; write greeting to uart
.lddst uart_send_string
puship
jmpdst
.lddst uart_flush ; wait until flushed
puship
jmpdst
halt
;
; ROM data
;
......
......@@ -8,6 +8,10 @@ UART_0_RBR:
.global UART_0_THR
UART_0_THR:
.org 0x2013
.global UART_0_LCR
UART_0_LCR:
.org 0x2015
.global UART_0_LSR
UART_0_LSR:
......
.global uart_init
.global uart_send_byte
.global uart_send_string
.global uart_flush
uart_init:
.ldsrc UART_0_LCR
.lddst UART_0_LCR
ld r0 ; set DLAB
imm r1, 0b10000000
or r0, r1
st r0
.lddst UART_0_RBR ; set DLL
imm r2, 4
st r2
.lddst UART_0_THR ; set DLM
imm r2, 0
st r2
neg r1 ; reset DLAB
.lddst UART_0_LCR
and r0, r1
st r0
pop r6 ; ret
pop r7
jmpdst
; send the byte in r0 to the uart
; if the transmit register is not empty, waits for it to become empty
......@@ -29,8 +56,9 @@ uart_send_string:
push r4
push r5
.lddst uart_send_byte
puship
jre uart_send_byte
jmpdst
pop r5
pop r4
......@@ -46,3 +74,16 @@ _uart_send_string_done:
pop r7
jmpdst
; wait until uart is finished (TEMT=1)
;
uart_flush:
.ldsrc UART_0_LSR ; load LSR
ld r0
imm r1, 0b01000000 ; bit6 = TEMT
and r0, r1
jzre uart_flush ; loop until TEMT = 1
pop r6
pop r7
jmpdst ; ret
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment