X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device%2Flib%2Fz80%2Fcrt0.s;h=23843568f76eec4bf474141185bc912f3c3102cf;hb=c4b55ee40ddb79b816c42b1567dc9b5858153b66;hp=c05ae1d18d31d2a1e1cf98556c0a9f7ec2eebc17;hpb=15f79deb6cf094bc83de7ade9e272b1ebfd4f640;p=fw%2Fsdcc diff --git a/device/lib/z80/crt0.s b/device/lib/z80/crt0.s index c05ae1d1..23843568 100644 --- a/device/lib/z80/crt0.s +++ b/device/lib/z80/crt0.s @@ -63,6 +63,57 @@ _exit:: halt jr 1$ + ;; Special RLE decoder used for initing global data +__initrleblock:: + ;; Pop the return address + pop hl + ;; Save registers + push bc + push de + + ;; Pull the destination address out + ld c,(hl) + inc hl + ld b,(hl) + inc hl +1$: + ;; Fetch the run + ld e,(hl) + inc hl + ;; Negative means a run + bit 7,e + jp z,2$ + ;; Code for expanding a run + ld a,(hl) + inc hl +3$: + ld (bc),a + inc bc + inc e + jp nz,3$ + jp 1$ +2$: + ;; Zero means end of a block + xor a + or e + jp z,4$ + ;; Code for expanding a block +5$: + ld a,(hl) + inc hl + ld (bc),a + inc bc + dec e + jp nz,5$ + jp 1$ +4$: + pop de + pop bc + + ;; Push the return address back onto the stack + push hl + ret + .area _GSINIT gsinit::