aboutsummaryrefslogtreecommitdiff
path: root/newasm/uart.s
diff options
context:
space:
mode:
authorJacques Comeaux <jacquesrcomeaux@protonmail.com>2024-08-21 00:21:54 -0500
committerJacques Comeaux <jacquesrcomeaux@protonmail.com>2024-08-21 00:21:54 -0500
commited6f1106322f8ca4a6e26d08365bb9558ffa9d09 (patch)
tree0258d4a7b0429c82b4f7af8d63106ea93e7150de /newasm/uart.s
parentd23ab4295a865580f6cb7bb4526978bac388b5ac (diff)
Start new assembler
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}