home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
ENTERPRS
/
CPM
/
UTILS
/
A
/
CRLZH21.LBR
/
PUTCODE.MYC
/
PUTCODE.MYC
Wrap
Text File
|
2000-06-30
|
1KB
|
51 lines
;
; PUTCODE_ - Output bit encoded string to file
;
; Action - Takes a bit-encoded string and concatenates it to any partial
; one left behind from previous invocation. If a full byte is
; available, it is output. A partial byte (or any residue
; after a byte is output) is saved for the next invocation.
; Input - H/L is the bit string to be output (in the most significant
; 'A-reg' bits)
; A is the length of bit string
; Output - See Action
; Entry - Putcode_
; Registers - All scratch except B/C (preserved)
; Calls - Putc_
;
;typedef unsigned char uchar;
;
;void Putcode(int l, unsigned c) /* output c bits */
;{
;extern FILE *outfile;
;extern unsigned putbuf;
;extern uchar putlen;
; putbuf |= c >> putlen;
; if ((putlen += l) >= 8) {
; putc(putbuf >> 8, outfile);
; if ((putlen -= 8) >= 8) {
; putc(putbuf, outfile);
; codesize += 2;
; putlen -= 8;
; putbuf = c << (l - putlen);
; } else {
; putbuf <<= 8;
; }
; }
;}
PUTCODE_:
MOV B,A ; Copy count
MVI A,00H ; Load partial buffer
CSAVE EQU $-1
LP2: DAD H ; Shift left
RAL ; Shift CY to A
JNC BOT ; If A not full, save it and return
CALL PUTC_ ; Output full byte in a, preserve regs.
MVI A,01B ; Prepare CY when next 8 bits have been gotten
BOT: DCR B ; Count
JNZ LP2 ; Continue
STA CSAVE ; Save for next time
RET ; And Exit