-
Notifications
You must be signed in to change notification settings - Fork 2
/
debitbustp0.asm
86 lines (64 loc) · 1.04 KB
/
debitbustp0.asm
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
;In: HL: source
; DE: destination
ld a,128
jr main_loop
get_length_loop:
call get_bit
rl c
rl d
get_bit_length_end:
djnz get_length_loop
ld b,d ; bc = length - 1
pop de ; de = (sp++++) = dest-offset
jr c,exit
ex (sp),hl ; (sp) = source, hl = dest
ex de,hl ; hl = dest-offset, de = dest
ldir
ldi
pop hl ; hl = (sp++++) = source
db 0DAh ; 0DAh: z80 opcode JP C,nnnn
one_literal:
ldi
main_loop:
call get_bit
jr nc,one_literal
get_offset:
ld c,(hl)
inc hl
bit 7,c
jr nz,long_offset
ld b,0
apply_offset:
push de ; (----sp) = dest
ex de,hl
sbc hl,bc
ex de,hl
push de ; (----sp) = dest-offset
ld bc,1
ld d,b
get_bit_length_loop:
inc b
call get_bit
jr c,get_bit_length_loop
jr get_bit_length_end
exit:
pop de
;ret
get_bit:
add a
ret nz
ld a,(hl)
inc hl
adc a,a
ret
long_offset:
ld b,0c0h
long_offset_loop:
call get_bit
rl b
jr c,long_offset_loop
call get_bit
jr c,apply_offset
res 7,c
scf
jr apply_offset