aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/uart.S
blob: e4767998326e8d7c6f22a71e6f45ede60311e1c9 (plain)
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
45
46
47
48
49
50
51
52
53
.section ".text"

.globl uart_char
uart_char:
	mov r2, #0x1000
	movt r2, #0x3f20
uart_char.loop:
	ldr r3, [r2, #24]
	tst r3, #0b100000
	bne uart_char.loop
	str r0, [r2]
	bx lr

.globl uart_string
uart_string:
	push    {r4, lr}
	mov     r4, r0
	ldrb    r0, [r0]
	cmp     r0, #0
	popeq   {r4, pc}
uart_string.loop:
	bl      uart_char
	ldrb    r0, [r4, #1]!
	cmp     r0, #0
	bne     uart_string.loop
	pop     {r4, pc}

.globl uart_hex
uart_hex:
	push {r4, lr}
	mov r2, #0x1000
	movt r2, #0x3f20
uart_hex.loop:
	ldr r3, [r2, #24]
	tst r3, #0b100000
	bne uart_hex.loop
	mov r3, #7
uart_hex.hloop:
	mov r1, r0
	asr r1, r3
	asr r1, r3
	asr r1, r3
	asr r1, r3
	and r1, #0xf
	add r1, #0x30
	cmp r1, #0x3A
	blt uart_hex.print
	add r1, #7
uart_hex.print:
	str r1, [r2]
	subs r3, #1
	bge uart_hex.hloop
	pop {r4, pc}