assert tree[0x34] & ~0x20 == 0x18 # clc
bits = tree[0x33] | ((tree[0x34] & 0x20) << 3)
-assert tree[0x5c] == 0x4c # jmp NNNN
-start = tree[0x5d] | (tree[0x5e] << 8)
+assert tree[0x65] == 0x4c # jmp NNNN
+start = tree[0x66] | (tree[0x67] << 8)
assert src == load_addr + len(tree) - 0x300
dest += 1
j = len(bin)
while count < 0:
i -= n
- assert i >= 0x86
+ assert i >= 0x98
j = decode(tree[i:i + n], bits, j)
i -= 1
- assert i >= 0x86 - 1 # last one is garbage
+ assert i >= 0x98 - 1 # last one is garbage
bits = (tree[i] << 1) | 1
n = 8
count += 1
-assert i == 0x86 - 1 # last one is garbage
+assert i == 0x98 - 1 # last one is garbage
assert j == 0
load_addr = start
with open(tree_loader_bin, 'rb') as fin:
tree_loader = list(fin.read())
-assert len(tree_loader) == 0x86
+assert len(tree_loader) == 0x98
with open(in_bin, 'rb') as fin:
data = list(fin.read())
assert tree[0x34] == 0x18 # clc
tree[0x34] |= (bits >> 3) & 0x20 # clc or sec
-assert tree[0x5c] == 0x4c # jmp NNNN
-tree[0x5d] = start & 0xff
-tree[0x5e] = start >> 8
+assert tree[0x65] == 0x4c # jmp NNNN
+tree[0x66] = start & 0xff
+tree[0x67] = start >> 8
-assert tree[0x61] == 0xbd # lda NNNN,x
-tree[0x62] = high1 & 0xff
-tree[0x63] = high1 >> 8
+assert tree[0x6a] == 0xbd # lda NNNN,x
+tree[0x6b] = high1 & 0xff
+tree[0x6c] = high1 >> 8
-assert tree[0x65] == 0xbd # lda NNNN,x
-tree[0x66] = right1 & 0xff
-tree[0x67] = right1 >> 8
+assert tree[0x6e] == 0xbd # lda NNNN,x
+tree[0x6f] = right1 & 0xff
+tree[0x70] = right1 >> 8
-assert tree[0x6d] == 0xbd # lda NNNN,x
-tree[0x6e] = high1 & 0xff
-tree[0x6f] = high1 >> 8
+assert tree[0x7f] == 0xbd # lda NNNN,x
+tree[0x80] = high1 & 0xff
+tree[0x81] = high1 >> 8
-assert tree[0x71] == 0xbd # lda NNNN,x
-tree[0x72] = left1 & 0xff
-tree[0x73] = left1 >> 8
+assert tree[0x83] == 0xbd # lda NNNN,x
+tree[0x84] = left1 & 0xff
+tree[0x85] = left1 >> 8
load_size = len(tree)
hdr = [load_addr & 0xff, load_addr >> 8, load_size & 0xff, load_size >> 8]
.r65c02
+FASTER = 1
+
.area zpage
.setdp
0$: dec src
lda [src],y
-.if 1
+.if FASTER
+ bcs token
+ sta [dest],y
+
+ lda dest
+ bne 1$
+ dec dest + 1
+1$: dec dest
+.else ; smaller
jmp expand
-expand_ret0:
-.else
- jsr expand
.endif
+expand_ret0:
;clc
rol bits
bne loop1
jmp 0
-token: pha
+token: ; enter with 9-bit byte in cf:a (and we know cf=1, it is token)
+ pha
tax
; asxxxx inconsistency:
asl a
lda 0xaaaa,x ; right1 (above decoded data)
-.if 1
+.if FASTER
+ bcs token
+ sta [dest],y
+
+ lda dest
+ bne 0$
+ dec dest + 1
+0$: dec dest
+.else ; smaller
jmp expand
-expand_ret1:
-.else
- jsr expand
.endif
+expand_ret1:
pla
tax
lsr a
lda 0xaaaa,x ; left1 (above decoded data)
-expand: ; a = token bits 0..7, cf = token bit 8
+expand: ; enter with 9-bit byte in cf:a
bcs token
-
sta [dest],y
lda dest
dec dest + 1
0$: dec dest
-.if 1
tsx
inx
- beq expand_ret0
+ beq expand_ret0 ; we need cf=0 here
bne expand_ret1
-.else
- rts
-.endif