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
/
ENCODEPO.MYC
/
ENCODEPO.MYC
Wrap
Text File
|
2000-06-30
|
2KB
|
81 lines
;
; ENCODEPO_ - Encode buffer postion and output
;
; Action - The relative buffer position is encoded and output.
; Input - match_po_ is the (relative) match position
; Output - As above
; Entry - encodepo_
; Registers - All scratch except B/C (preserved)
; Calls - putcode_
; Additional notes:
; The original algorithm used a 4096 character buffer, requiring
; Encoding for 12 bits (0-4095). Space for auxilliary tables
; necessitated the shortening of the buffer to 2048 for the CP/M
; version. This made the most significant bit of the index 0.
; Version 1 encoding made use of this fact. The encoding data tables were
; 'shortend' to reflect the fact that only 5 bits of the upper 6 were
; non-zero. However, since the design wasn't 'finalized', the generalized
; 12-bit encoding capability was preserved.
;
; With version 2 encoding, the decision to employ the additional (or
; original) capability of the encoding algorithm was made. This results
; in slightly better compression capability (the version 1 encoding caused
; a certain amount of usable information bits to go unused). Since the
; index is still only 11 bits in lenght, version 2 encoding table-encodes
; the upper 6 bits and sends the lower 5 bits out directly.
;extern char p_len[],p_code[];
;
;void EncodePosition(unsigned c)
;{
; unsigned i;
CSEG
ENCODEPO_:
PUSH B ; Save general counter regs
; /* output upper 6 bits with encoding */
; i = c >> 6;
LHLD MATCH_PO_
DAD H ; Same as shift left 2
DAD H ; And use high byte
IF VERS2
DAD H ; Version 2 requires 1 more shift for
; Upper 6 bits
ENDIF
MOV A,L ; Get low
STA LOWSAVE ; Save for later
MOV C,H ; Get high
MVI B,0 ; Convert to 16 bits
; Putcode(p_len[i], (unsigned)p_code[i] << 8);
LXI H,P_LEN_
DAD B ; Get index
MOV A,M ; Get length
LXI H,P_CODE_ ; Get code
DAD B ; Index
MOV H,M ; Get into high
CALL PUTCODE_
;
; /* output lower 6 bits directly */
; Putcode(6, (c & 0x3f) << 10);
MVI H,0 ; Low of shl x
LOWSAVE EQU $-1
IF VERS2
MVI A,5 ; Only 5 bits for version 2
ELSE
MVI A,6 ; 6 bits for version 1
ENDIF
CALL PUTCODE_
;}
POP B ; Restore entry B/C
RET