summary refs log tree commit diff
path: root/pc-thing/code/move-bootloader.a
diff options
context:
space:
mode:
authorWlodekM <[email protected]>2025-03-31 19:47:54 +0300
committerWlodekM <[email protected]>2025-03-31 19:47:54 +0300
commitcccb99226d3951fd9dfe1c4cf1c43126a1309d51 (patch)
tree518d3e965558ba313f103cee6161cd2b6aedb3b9 /pc-thing/code/move-bootloader.a
parentef4e8c20719822eebd6318a878cc37902c2b85a5 (diff)
move to pc-thing/
Diffstat (limited to 'pc-thing/code/move-bootloader.a')
-rw-r--r--pc-thing/code/move-bootloader.a62
1 files changed, 62 insertions, 0 deletions
diff --git a/pc-thing/code/move-bootloader.a b/pc-thing/code/move-bootloader.a
new file mode 100644
index 0000000..306f2fe
--- /dev/null
+++ b/pc-thing/code/move-bootloader.a
@@ -0,0 +1,62 @@
+start:
+    ; init stack
+    mov a 0x6000
+    mov b 0x7000
+    str b a
+    copyLoop:
+        mov a [codePointer]
+        ld a a
+        mov b 0x6000
+        add c a b
+        mov a [targetPointer]
+        str c a
+
+        mov a codeStart
+        mov b [codePointer]
+        ld b b
+        add c a b
+        
+        mov a [targetPointer]
+        ld a a
+        ; swp a c
+        ; a <- $b
+        ld d c
+        push d ; push b
+        ld d a
+        ; push a ; push a
+        str c d ; $b <- a
+        pop d
+        ; $a <- b
+        str a d
+        ; swpm c b
+        
+        mov a [codePointer]
+        ld a a
+        mov b 1
+        add c a b
+        ; mov a
+        str c [codePointer] 
+        ; continue loop
+            mov b [targetPointer]
+            ; (byte we just copied) -> B
+            ld b b
+            ; (next byte) -> A
+            ld a c
+            ; C = A (aka next byte) == 0
+            cmr c a 0
+            ; A = B (aka last byte) == 1E (end instruction)
+            cmr a b 0x1e
+            swp c b ; C -> B
+            and c a b; c=a&&b
+            mov a 1
+            cmp c a ; c==1?
+            jz copyLoop ; continue if c != 1
+    jmp 0x6001
+
+
+targetPointer:
+.hex 0
+codePointer:
+.hex 0
+; start of bootloader
+codeStart:
\ No newline at end of file