blob: 306f2fe3a09f451e5336b00f15178d3c11c99fcb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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:
|