Imported Upstream version 2.9.0
[debian/cc1111] / device / lib / z80 / crt0_rle.s
1         .area   _CODE
2
3         ;; Special RLE decoder used for initing global data
4 __initrleblock::
5         ;; Pull the destination address out
6         ld      c,l
7         ld      b,h
8
9         ;; Pop the return address
10         pop     hl
11 1$:
12         ;; Fetch the run
13         ld      e,(hl)
14         inc     hl
15         ;; Negative means a run
16         bit     7,e
17         jp      Z,2$
18         ;; Code for expanding a run
19         ld      a,(hl)
20         inc     hl
21 3$:
22         ld      (bc),a
23         inc     bc
24         inc     e
25         jp      NZ,3$
26         jp      1$
27 2$:
28         ;; Zero means end of a block
29         xor     a
30         or      e
31         jp      Z,4$
32         ;; Code for expanding a block
33 5$:
34         ld      a,(hl)
35         inc     hl
36         ld      (bc),a
37         inc     bc
38         dec     e
39         jp      NZ,5$
40         jp      1$
41 4$:
42         ;; Push the return address back onto the stack
43         push    hl
44         ret
45