Add UART demo program

This commit is contained in:
Graham Edgecombe 2017-12-07 22:12:50 +00:00
parent 66089359fe
commit 9f036f6630

View file

@ -1,20 +1,18 @@
li t0, 7 # set baud rate to 9600
li t1, 3 li t0, 0x00020000
li t2, 0 li t1, 3750
sw t1, 0(t0)
# t2 = t0 * t1 # read char from the UART
mul: li t0, 0x00020008
beqz t0, mul_done li t1, 0x00010000
andi t3, t0, 1 loop:
beqz t3, mul_even lw t2, 0(t0)
add t2, t2, t1 bltz t2, loop
mul_even:
srli t0, t0, 1
slli t1, t1, 1
j mul
# display results on the LEDs # write to the LEDs
mul_done:
li t0, 0x00010000
sw t2, 0(t0) sw t2, 0(t0)
j .
# echo back to the UART
sw t2, 0(t1)
j loop