aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorJacques Comeaux <jacquesrcomeaux@protonmail.com>2024-07-01 12:16:02 -0500
committerJacques Comeaux <jacquesrcomeaux@protonmail.com>2024-07-01 12:16:02 -0500
commit83aef192e447c800cba6f4dbde8a450a4f8581a5 (patch)
treec5b21bb6238d9117057f3433d4122d66f4add9f8 /misc
parent4e018fc5bdd4ff9ee6065a5167fa291404e20576 (diff)
Use in-house CRC32 computation for boot sector
Diffstat (limited to 'misc')
-rw-r--r--misc/crc.s24
1 files changed, 24 insertions, 0 deletions
diff --git a/misc/crc.s b/misc/crc.s
new file mode 100644
index 0000000..03c0ce2
--- /dev/null
+++ b/misc/crc.s
@@ -0,0 +1,24 @@
+.syntax unified
+.cpu cortex-m0plus
+.thumb
+
+.type CRC32, %function
+.global CRC32
+
+// R0 = input addr
+// R1 = length
+CRC32: LDR R5, =0x04C11DB7
+ LDR R4, =0xFFFFFFFF
+10: LDR R2, [R0]
+ REV R2, R2;
+ EORS R4, R2
+ MOVS R3, 32
+20: LSLS R4, 1
+ BCC 30f
+ EORS R4, R5
+30: SUBS R3, 1
+ BNE 20b
+ ADDS R0, 4
+ SUBS R1, 1
+ BNE 10b
+ BX LR