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
|
.syntax unified
.cpu cortex-m0plus
.thumb
.type uart_send, %function
.type uart_recv, %function
.type send_hex, %function
.global uart_send
.global uart_recv
.global send_hex
uart_send: LDR R1, =0x40034000
MOVS R3, 0x20
1: LDR R2, [R1, 0x18]
TST R2, R3
BNE 1b
STRB R0, [R1]
BX LR
uart_recv: LDR R1, =0x40034000
MOVS R3, 0x10
1: LDR R2, [R1, 0x18]
TST R2, R3
BNE 1b
LDRB R0, [R1]
BX LR
send_hex: PUSH {R4, R5, LR}
MOVS R4, R0
MOVS R5, 8
0: MOVS R0, 0x1C
RORS R4, R0
MOVS R0, 0x0F
ANDS R0, R4
CMP R0, 0x9
BHI 1f
ADDS R0, 0x30
B 2f
1: ADDS R0, 0x37
2: BL uart_send
SUBS R5, 1
BNE 0b
POP {R4, R5, PC}
|