CompressBinaryStrings_7bit: ; HL = pointer to output ; DE = pointer to input. Input is assumed to equal &30 or &31 ; Usage: ; LD hl,OutputRam ; LD de,InputRam ; CALL CompressBinaryStrings_7bit ; If the string "runs out" before the 8 bit boundary, the rest are rotated into place. ; e.g. input = "0101" then the procedure will RLC until those bits ; are as far left as possible. outerloop: inc de ;skip bit 7 ld b,7 ;loop counter innerloop: ld a,(de) or a ;compares accumulator to zero. Assumes a null-terminated string. ; Otherwise compare A to your terminator of choice. jr z,HandleEarlyExit ;input is assumed to be &30 or &31, so the least significant bit tells us ; all we need to know. The rest of the byte can be discarded. rra ;rotate the result into the carry rl (hl) ;rotate it out of the carry into (HL) inc de z_djnz innerloop ;a macro that becomes DJNZ