aboutsummaryrefslogtreecommitdiff
path: root/newasm/uart.s
diff options
context:
space:
mode:
Diffstat (limited to 'newasm/uart.s')
-rw-r--r--newasm/uart.s44
1 files changed, 44 insertions, 0 deletions
diff --git a/newasm/uart.s b/newasm/uart.s
new file mode 100644
index 0000000..c4abb8a
--- /dev/null
+++ b/newasm/uart.s
@@ -0,0 +1,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}