-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuart_trans.S
More file actions
44 lines (36 loc) · 971 Bytes
/
Copy pathuart_trans.S
File metadata and controls
44 lines (36 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
.global _uartTransByte
.global _uartTransLine
.include "uart.inc"
_uartTransLine:
addi sp, sp, -16 # move back store pointer to ad return address to the stack
sw ra, 12(sp) # store return address to the stack
li t0, UART_CTRL_ADDR_0 # load the address for the UART base address
mv t1, x0 # have t1 be the storage of the byte of the line
mv t5, a2 # store the address of the string to t5 register for easier manipulation
transLine:
lb t1, (t5)
beqz t1, exit_uart # If at end of string character (i.e ascii 0) exit transfer
call transByte
addi t5,t5, 0x1
j transLine
transByte:
lw t2, 0(t0)
li t3, 0x80000000
bne t2, t3, transByte
beq t2, t3, wait
_uartTransByte:
addi sp, sp, -16 # store the return address
sw ra, 12(sp) # store the return address
li t0, UART_CTRL_ADDR_0 # loading UART CTRL ADDR
mv t1, a2
call transByte
j exit_uart
send:
sw t1, 0(t0)
li t1, 0b11
sw t1, TXCTRL(t0)
ret
exit_uart:
lw ra, 12(sp)
addi sp, sp, 16
ret