aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Comeaux <jacquesrcomeaux@protonmail.com>2024-07-20 01:38:55 -0500
committerJacques Comeaux <jacquesrcomeaux@protonmail.com>2024-07-20 01:38:55 -0500
commit513531360fe050bcd3598a34dac25afa496fd4b2 (patch)
tree5dfa3d99fe0d9a8f17445595d02eb01b6d718c43
parentf0eb0cdec747d5e1c7165b8b1ad44a888ec9826e (diff)
Move string comparison
-rw-r--r--better_assembler/main.as2
-rw-r--r--better_assembler/string.as13
-rw-r--r--misc/string.s16
3 files changed, 13 insertions, 18 deletions
diff --git a/better_assembler/main.as b/better_assembler/main.as
index 28b5139..d83e469 100644
--- a/better_assembler/main.as
+++ b/better_assembler/main.as
@@ -5,7 +5,7 @@ JIH 0000 print string
JIL 0174
DRF R0 R4
JIH 0000 read string
-JIL 0371
+JIL 0271
JA 3770 infinite loop
Q 0014 00
Q 0200 00
diff --git a/better_assembler/string.as b/better_assembler/string.as
index 35f9248..c42c4b6 100644
--- a/better_assembler/string.as
+++ b/better_assembler/string.as
@@ -17,7 +17,7 @@ JA 3766 next char
JR R14 jump to link register
Q 0400 00 uart zero base
Q 0400 03
-<0200 getstr
+<0180 getstr
register zero : string offset
register one : current character, uart status
register two : rx fifo empty bitmask
@@ -46,3 +46,14 @@ JR R14 jump to link register
Q 0000 00 alignment
Q 0400 00 uart zero base
Q 0400 03
+<0200 cmpstr
+DI R4 0
+LBR R2 R0 R4
+LBR R3 R1 R4
+CR3 R2 R3
+JN 3
+CI R2 0
+JE 1
+AAI8 R4 1
+JA 3767
+JR R14
diff --git a/misc/string.s b/misc/string.s
deleted file mode 100644
index 0ed7ca3..0000000
--- a/misc/string.s
+++ /dev/null
@@ -1,16 +0,0 @@
-// R0 : string1 address
-// R1 : string2 address
-// Result in R0
-string_compare:
- MOVS R4, 0
-loop:
- LDRB R2, [R0, R4]
- LDRB R3, [R1, R4]
- CMP R2, R3
- BNE done
- CMP R2, 0
- BEQ done
- ADDS R4, 1
- B loop
-done:
- BX LR