.z80 .phase 0bd00h defb 7fh,7fh,'KOMP',1 kompress: push hl ld b,h ;Adresse Quelle in HL ld c,l ;Adresse Ziel in BC komp1: ld a,(hl) cp 20 ;Leerzeichen werden nicht sofort jr z,komp2 ;in Ziel kopiert ld (bc),a komp6: inc hl inc bc ;naechste Adresse ld a,d cp h jr nz,komp1 ld a,e cp l jr nz,komp1 pop hl ;Ende erreicht call 0f003h defb 1bh push bc pop hl call 0f003h db 1ah ret komp2: ld a,0c0h ld (bc),a ;schon ein Leerzeichen=0C0H komp3: inc hl ld a,d cp h jr nz,komp4 ld a,e cp l jr nz,komp4 inc bc ;Ende erreicht pop hl call 0f003h defb 1bh push bc pop hl call 0f003h db 1ah ret komp4: ld a,(hl) cp 20h jr nz,komp5 ld a,(bc) inc a ld (bc),a inc a ;max erlaubte Zahl in (BC) ist 0FFH jr nz,komp3 jr komp6 komp5: inc bc jr komp1 ; defb 7fh,7fh,'EXP',1 expand: push hl ;Anf.adr. push de ;Ende+1 norm push bc ;Ende+1 komp ;Ermitteln Laenge, BC=BC-HL push hl push bc pop hl pop bc or a sbc hl,bc ld b,h ld c,l ;Laenge ist pop hl ;Ende+1 komp dec hl pop de ;Ende+1 norm dec de push bc lddr ;kompr Text an Ende verschieben pop bc ;in BC ist Laenge komp. Text pop de ;in DE ist Anf.adr norm. Text inc hl ;in HL ist Anf.adr komp. Text exp1: ld a,(hl) sub 0c0h jr c,exp2 jr nz,exp3 exp4: ld (hl),20h exp2: ldi jp pe,exp1 ret exp3: push bc push hl ld b,0 ld c,a ld h,d ld l,e ld (hl),20h inc de ldir dec de pop hl pop bc jr exp4 end