aboutsummaryrefslogtreecommitdiff
path: root/newasm/whitespace.s
diff options
context:
space:
mode:
authorJacques Comeaux <jacquesrcomeaux@protonmail.com>2024-08-21 03:18:35 -0500
committerJacques Comeaux <jacquesrcomeaux@protonmail.com>2024-08-21 03:18:35 -0500
commitccc04526f14764d856ad37b1f517308fccf886a6 (patch)
tree7c25442967b071a485a44c1da73b16ba84adc9af /newasm/whitespace.s
parented6f1106322f8ca4a6e26d08365bb9558ffa9d09 (diff)
Add label and opcode parsers
Diffstat (limited to 'newasm/whitespace.s')
-rw-r--r--newasm/whitespace.s21
1 files changed, 21 insertions, 0 deletions
diff --git a/newasm/whitespace.s b/newasm/whitespace.s
new file mode 100644
index 0000000..f4d8d9f
--- /dev/null
+++ b/newasm/whitespace.s
@@ -0,0 +1,21 @@
+.syntax unified
+.cpu cortex-m0plus
+.thumb
+
+.type whitespace, %function
+.global whitespace
+
+// 1 unexpected char
+
+whitespace:
+ LDRB R0, [R1] // get a char
+ CMP R0, ' // space
+ BEQ 1f
+ MOVS R0, #1 // return code 1 (unexpected char)
+ BX LR
+1: ADDS R1, 1 // consume the character
+ LDRB R0, [R1] // get another character
+ CMP R0, ' // check if space
+ BEQ 1b // if so keep getting chars
+ MOVS R0, #0 // return code 0 (success)
+ BX LR