v05i075: u16 2 of 2 - 16 bit uncompress for IBM PC
Tom Horsley
tom at SSD.HARRIS.COM
Thu Dec 8 10:02:04 AEST 1988
Posting-number: Volume 5, Issue 75
Submitted-by: "Tom Horsley" <tom at SSD.HARRIS.COM>
Archive-name: u16.pc/part02
u16 is a 16 bit LZW uncompress program for the IBM PC. It can
decompress any files compressed with the net "compress" utility.
--------------------------cut here-----------------------------
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 2 (of 2)."
# Contents: xcode.asm
# Wrapped by tom at hcx2 on Tue Dec 6 10:58:19 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'xcode.asm' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'xcode.asm'\"
else
echo shar: Extracting \"'xcode.asm'\" \(24436 characters\)
sed "s/^X//" >'xcode.asm' <<'END_OF_FILE'
X; xcode is the assembler optimized variable sized packed code
X; extraction routines. Written by Tom Horsley
X; (tahorsley at ssd.harris.com) Dec 1988.
X;
X; struct codebuf {
X; void near (*codep)();
X; char near * bufp;
X; };
X;
X; extern unsigned int near xcode(struct codebuf near * cbp)
X;
X; xcode extracts the next variable sized code from the buffer pointed
X; at by bufp. The codep function pointer is a state variable recording
X; the address of the routine that will be used to extract the next
X; code byte.
X;
X; xcode works by jumping to the codep address. Each code extraction
X; routine extracts the specific offset code it is designed for then
X; sets codep to point to the next routine that will extract the next
X; code. Eventually we sync up on a byte boundary and start over again
X; with the original routine.
X;
X; Note: As you can see below, this uses the new .MODEL directive
X; Microsoft introduced sometime around 5.0, so you need the latest
X; version of the assembler to build this.
X
X.MODEL SMALL
X.CODE
X PUBLIC _xcode
X_xcode PROC
X push bp
X mov bp,sp ; add code to push ss, ds, si, di
X push si
X
X mov bx,[bp+4] ; bx points to codebuf struct
X mov cx,[bx] ; cx points to routine
X mov si,[bx+2] ; si points to data buffer
X call cx ; go make state transition
X mov [bx],cx ; save new state routine
X mov [bx+2],si ; save new buffer ptr
X
X pop si
X pop bp ; add code to pop di, si, ds, ss
X ret
X_xcode ENDP
X
X; The following code implements all the code extraction routines.
X; Because of the way that the net compress utility works there are
X; eight routines for each size code from 9 to 15 bits. For 10, 12, 14,
X; and 16 bits we could do with fewer routines since we sync up on a
X; byte boundary before looking at n_bits bytes, but the compress.c
X; code always flushes out to n_bits byte boundary when changing code
X; size, so there are 8 routines not just to extract codes, but also to
X; maintain unique state information so that a buffer flush can get to
X; the correct byte boundary to find the next set of codes.
X;
X; A fanatic would probably say "My gosh! we are wasteing space!" and
X; implement a new magic number and a new compression algorithm to
X; recover the dozen or so bytes wasted, but since I am not (that sort
X; of) a fanatic, and I like the idea of sticking to standards, I leave
X; it the way it is. (P.S. The percentage of wasted space is somewhere
X; around .000001, so there is no real reason to get upset).
X
X; ********************************************** 9 bit code extraction routines
X
X PUBLIC _init9
X_init9 PROC
X push bp
X mov bp,sp
X mov bx,[bp+4] ; bx points to codebuf struct
X mov cx,offset g9c0 ; initialize state to g9c0
X mov [bx],cx ; save new state routine
X pop bp
X ret
X_init9 ENDP
X
X; g9c0 get 9 bit code 0: 11111111 -------1
X
Xg9c0 PROC
X mov ax,[si] ; get low in al, high bit in ah
X and ah,001h ; mask off junk
X inc si ; skip past first byte
X mov cx,offset g9c1 ; point to next code routine
X ret
Xg9c0 ENDP
X
X; g9c1 get 9 bit code 1: 1111111- ------11
X
Xg9c1 PROC
X mov ax,[si] ; get data in ax << 1
X shr ax,1 ; position correctly
X and ah,001h ; mask junk
X inc si ; skip to next
X mov cx,offset g9c2 ; point to next code routine
X ret
Xg9c1 ENDP
X
X; g9c2 get 9 bit code 2: 111111-- -----111
X
Xg9c2 PROC
X mov ax,[si] ; get data in ax << 2
X shr ax,1 ; position correctly
X shr ax,1
X and ah,001h ; mask junk
X inc si ; skip to next
X mov cx,offset g9c3 ; point to next code routine
X ret
Xg9c2 ENDP
X
X; g9c3 get 9 bit code 3: 11111--- ----1111
X
Xg9c3 PROC
X mov ax,[si] ; get data in ax << 3
X shr ax,1 ; position correctly
X shr ax,1
X shr ax,1
X and ah,001h ; mask junk
X inc si ; skip to next
X mov cx,offset g9c4 ; point to next code routine
X ret
Xg9c3 ENDP
X
X; g9c4 get 9 bit code 4: 1111---- ---11111
X
Xg9c4 PROC
X mov ax,[si] ; get data in ax << 4
X shr ax,1 ; position correctly
X shr ax,1
X shr ax,1
X shr ax,1
X and ah,001h ; mask junk
X inc si ; skip to next
X mov cx,offset g9c5 ; point to next code routine
X ret
Xg9c4 ENDP
X
X; g9c5 get 9 bit code 5: 111----- --111111
X
Xg9c5 PROC
X mov ax,[si] ; ax = --123456 789-----
X xchg ah,al ; ax = 789----- --123456
X rol ax,1 ; ax = 89------ -1234567
X rol ax,1 ; ax = 9------- 12345678
X rol ax,1 ; ax = -------1 23456789
X and ah,001h ; mask junk
X inc si ; skip to next
X mov cx,offset g9c6 ; point to next code routine
X ret
Xg9c5 ENDP
X
X; g9c6 get 9 bit code 6: 11------ -1111111
X
Xg9c6 PROC
X mov ax,[si] ; ax = -1234567 89------
X xchg ah,al ; ax = 89------ -1234567
X rol ax,1 ; ax = 9------- 12345678
X rol ax,1 ; ax = -------1 23456789
X and ah,001h ; mask junk
X inc si ; skip to next
X mov cx,offset g9c7 ; point to next code routine
X ret
Xg9c6 ENDP
X
X; g9c7 get 9 bit code 7: 1------- 11111111
X
Xg9c7 PROC
X mov ax,[si] ; ax = 12345678 9-------
X xchg ah,al ; ax = 9------- 12345678
X rol ax,1 ; ax = -------1 23456789
X and ah,001h ; mask junk
X inc si ; skip to next
X inc si ; skip to next
X mov cx,offset g9c0 ; synced, point back to code 0 routine
X ret
Xg9c7 ENDP
X
X; ********************************************* 10 bit code extraction routines
X
X PUBLIC _init10
X_init10 PROC
X push bp
X mov bp,sp
X mov bx,[bp+4] ; bx points to codebuf struct
X mov cx,offset g10c0 ; initialize state to g10c0
X mov [bx],cx ; save new state routine
X pop bp
X ret
X_init10 ENDP
X
X; g10c0 get 10 bit code 0: 11111111 ------11
X
Xg10c0 PROC
X mov ax,[si] ; code in ax
X and ah,003h ; mask off junk
X inc si ; point to next byte
X mov cx,offset g10c1 ; point to next code routine
X ret
Xg10c0 ENDP
X
X; g10c1 get 10 bit code 1: 111111-- ----1111
X
Xg10c1 PROC
X mov ax,[si] ; ax = ----1234 56789a--
X shr ax,1 ; ax = -----123 456789a-
X shr ax,1 ; ax = ------12 3456789a
X and ah,003h ; mask off junk
X inc si ; point to next byte
X mov cx,offset g10c2 ; point to next code routine
X ret
Xg10c1 ENDP
X
X; g10c2 get 10 bit code 2: 1111---- --111111
X
Xg10c2 PROC
X mov ax,[si] ; ax = --123456 789a----
X shr ax,1 ; ax = ---12345 6789a---
X shr ax,1 ; ax = ----1234 56789a--
X shr ax,1 ; ax = -----123 456789a-
X shr ax,1 ; ax = ------12 3456789a
X and ah,003h ; mask off junk
X inc si ; point to next byte
X mov cx,offset g10c3 ; point to next code routine
X ret
Xg10c2 ENDP
X
X; g10c3 get 10 bit code 3: 11------ 11111111
X
Xg10c3 PROC
X mov ax,[si] ; ax = 12345678 9a------
X xchg ah,al ; ax = 9a------ 12345678
X rol ax,1 ; ax = a------1 23456789
X rol ax,1 ; ax = ------12 3456789a
X and ah,003h ; mask off junk
X inc si ; inc past code
X inc si
X mov cx,offset g10c4 ; point to next code routine
X ret
Xg10c3 ENDP
X
X; g10c4 get 10 bit code 4: 11111111 ------11
X
Xg10c4 PROC ; same as c0
X mov ax,[si]
X and ah,003h
X inc si
X mov cx,offset g10c5
X ret
Xg10c4 ENDP
X
X; g10c5 get 10 bit code 5: 111111-- ----1111
X
Xg10c5 PROC ; same as c1
X mov ax,[si]
X shr ax,1
X shr ax,1
X and ah,003h
X inc si
X mov cx,offset g10c6
X ret
Xg10c5 ENDP
X
X; g10c6 get 10 bit code 6: 1111---- --111111
X
Xg10c6 PROC ; same as c2
X mov ax,[si]
X shr ax,1
X shr ax,1
X shr ax,1
X shr ax,1
X and ah,003h
X inc si
X mov cx,offset g10c7
X ret
Xg10c6 ENDP
X
X; g10c7 get 10 bit code 3: 11------ 11111111
X
Xg10c7 PROC ; same as c3
X mov ax,[si]
X xchg ah,al
X rol ax,1
X rol ax,1
X and ah,003h
X inc si
X inc si
X mov cx,offset g10c0 ; synced, wrap back around
X ret
Xg10c7 ENDP
X
X; ********************************************* 11 bit code extraction routines
X
X PUBLIC _init11
X_init11 PROC
X push bp
X mov bp,sp
X mov bx,[bp+4] ; bx points to codebuf struct
X mov cx,offset g11c0 ; initialize state to g11c0
X mov [bx],cx ; save new state routine
X pop bp
X ret
X_init11 ENDP
X
X; g11c0 get 11 bit code 0: 11111111 -----111
X
Xg11c0 PROC
X mov ax,[si] ; code in ax
X and ah,007h ; mask off junk
X inc si ; bump pointer
X mov cx,offset g11c1 ; point to next code routine
X ret
Xg11c0 ENDP
X
X; g11c1 get 11 bit code 1: 11111--- --111111
X
Xg11c1 PROC
X mov ax,[si] ; ax = --123456 789ab---
X shr ax,1 ; ax = ---12345 6789ab--
X shr ax,1 ; ax = ----1234 56789ab-
X shr ax,1 ; ax = -----123 456789ab
X and ah,007h ; mask off junk
X inc si ; bump pointer
X mov cx,offset g11c2 ; point to next code routine
X ret
Xg11c1 ENDP
X
X; g11c2 get 11 bit code 2: 11------ 11111111 -------1
X
Xg11c2 PROC
X mov ax,[si] ; ax = 23456789 ab------
X inc si ; bump pointer
X inc si
X mov cl,[si] ; cl = -------1
X rcr cl,1 ; carry bit = 1
X rcr ax,1 ; ax = 12345678 9ab-----
X xchg ah,al ; ax = 9ab----- 12345678
X rol ax,1 ; ax = ab-----1 23456789
X rol ax,1 ; ax = b-----12 3456789a
X rol ax,1 ; ax = -----123 456789ab
X and ah,007h ; mask off junk
X mov cx,offset g11c3 ; point to next code routine
X ret
Xg11c2 ENDP
X
X; g11c3 get 11 bit code 3: 1111111- ----1111
X
Xg11c3 PROC
X mov ax,[si] ; ax = ----1234 56789ab-
X shr ax,1 ; ax = -----123 456789ab
X and ah,007h ; mask off junk
X inc si ; next byte
X mov cx,offset g11c4 ; point to next code routine
X ret
Xg11c3 ENDP
X
X; g11c4 get 11 bit code 4: 1111---- -1111111
X
Xg11c4 PROC
X mov ax,[si] ; ax = -1234567 89ab----
X shr ax,1 ; ax = --123456 789ab---
X shr ax,1 ; ax = ---12345 6789ab--
X shr ax,1 ; ax = ----1234 56789ab-
X shr ax,1 ; ax = -----123 456789ab
X and ah,007h ; mask off junk
X inc si ; next byte
X mov cx,offset g11c5 ; point to next code routine
X ret
Xg11c4 ENDP
X
X; g11c5 get 11 bit code 5: 1------- 11111111 ------11
X
Xg11c5 PROC
X mov ax,[si] ; ax = 3456789a b-------
X and al,080h ; mask off junk
X inc si ; bump pointer
X inc si
X mov cl,[si] ; cl = ------12
X and cl,003h ; mask off junk
X or al,cl ; ax = 3456789a b-----12
X rol ax,1 ; ax = 456789ab -----123
X xchg ah,al ; ax = -----123 456789ab
X mov cx,offset g11c6 ; point to next code routine
X ret
Xg11c5 ENDP
X
X; g11c6 get 11 bit code 6: 111111-- ---11111
X
Xg11c6 PROC
X mov ax,[si] ; ax = ---12345 6789ab--
X shr ax,1 ; ax = ----1234 56789ab-
X shr ax,1 ; ax = -----123 456789ab
X and ah,007h ; mask off junk
X inc si ; bump pointer
X mov cx,offset g11c7 ; point to next code routine
X ret
Xg11c6 ENDP
X
X; g11c7 get 11 bit code 7: 111----- 11111111
X
Xg11c7 PROC
X mov ax,[si] ; ax = 12345678 9ab-----
X xchg ah,al ; ax = 9ab----- 12345678
X rol ax,1 ; ax = ab-----1 23456789
X rol ax,1 ; ax = b-----12 3456789a
X rol ax,1 ; ax = -----123 456789ab
X and ah,007h ; mask off junk
X inc si ; bump pointer
X inc si
X mov cx,offset g11c0 ; synced, wrap around
X ret
Xg11c7 ENDP
X
X; ********************************************* 12 bit code extraction routines
X
X PUBLIC _init12
X_init12 PROC
X push bp
X mov bp,sp
X mov bx,[bp+4] ; bx points to codebuf struct
X mov cx,offset g12c0 ; initialize state to g12c0
X mov [bx],cx ; save new state routine
X pop bp
X ret
X_init12 ENDP
X
X; g12c0 get 12 bit code 0: 11111111 ----1111
X
Xg12c0 PROC
X mov ax,[si] ; code in ax
X and ah,00fh ; mask off junk
X inc si ; next byte
X mov cx,offset g12c1 ; point to next routine
X ret
Xg12c0 ENDP
X
X; g12c1 get 12 bit code 1: 1111---- 11111111
X
Xg12c1 PROC
X mov ax,[si] ; ax = 12345678 9abc----
X shr ax,1 ; ax = -1234567 89abc---
X shr ax,1 ; ax = --123456 789abc--
X shr ax,1 ; ax = ---12345 6789abc-
X shr ax,1 ; ax = ----1234 56789abc
X inc si ; bump pointer
X inc si
X mov cx,offset g12c2 ; point to next routine
X ret
Xg12c1 ENDP
X
X; g12c2 get 12 bit code 2: 11111111 ----1111
X
Xg12c2 PROC ; same as 0
X mov ax,[si]
X and ah,00fh
X inc si
X mov cx,offset g12c3
X ret
Xg12c2 ENDP
X
X; g12c3 get 12 bit code 3: 1111---- 11111111
X
Xg12c3 PROC ; same as 1
X mov ax,[si]
X shr ax,1
X shr ax,1
X shr ax,1
X shr ax,1
X inc si
X inc si
X mov cx,offset g12c4
X ret
Xg12c3 ENDP
X
X; g12c4 get 12 bit code 4: 11111111 ----1111
X
Xg12c4 PROC ; same as 0
X mov ax,[si]
X and ah,00fh
X inc si
X mov cx,offset g12c5
X ret
Xg12c4 ENDP
X
X; g12c5 get 12 bit code 5: 1111---- 11111111
X
Xg12c5 PROC ; same as 1
X mov ax,[si]
X shr ax,1
X shr ax,1
X shr ax,1
X shr ax,1
X inc si
X inc si
X mov cx,offset g12c6
X ret
Xg12c5 ENDP
X
X; g12c6 get 12 bit code 6: 11111111 ----1111
X
Xg12c6 PROC ; same as 0
X mov ax,[si]
X and ah,00fh
X inc si
X mov cx,offset g12c7
X ret
Xg12c6 ENDP
X
X; g12c7 get 12 bit code 7: 1111---- 11111111
X
Xg12c7 PROC ; same as 1
X mov ax,[si]
X shr ax,1
X shr ax,1
X shr ax,1
X shr ax,1
X inc si
X inc si
X mov cx,offset g12c0 ; synced, wrap around
X ret
Xg12c7 ENDP
X
X; ********************************************* 13 bit code extraction routines
X
X PUBLIC _init13
X_init13 PROC
X push bp
X mov bp,sp
X mov bx,[bp+4] ; bx points to codebuf struct
X mov cx,offset g13c0 ; initialize state to g13c0
X mov [bx],cx ; save new state routine
X pop bp
X ret
X_init13 ENDP
X
X; g13c0 get 13 bit code 0: 11111111 ---11111
X
Xg13c0 PROC
X mov ax,[si] ; ax = 12345 6789abcd
X and ah,01fh ; mask off junk
X inc si ; bump pointer
X mov cx,offset g13c1 ; point to next routine
X ret
Xg13c0 ENDP
X
X; g13c1 get 13 bit code 1: 111----- 11111111 ------11
X
Xg13c1 PROC
X mov ax,[si] ; ax = 3456789a bcd-----
X and al,0e0h ; mask off junk
X inc si ; bump pointer
X inc si
X mov cl,[si] ; cl = ------12
X and cl,003h ; mask off junk
X or al,cl ; ax = 3456789a bcd---12
X rol ax,1 ; ax = 456789ab cd---123
X rol ax,1 ; ax = 56789abc d---1234
X rol ax,1 ; ax = 6789abcd ---12345
X xchg ah,al ; ax = ---12345 6789abcd
X mov cx,offset g13c2 ; point to next routine
X ret
Xg13c1 ENDP
X
X; g13c2 get 13 bit code 2: 111111-- -1111111
X
Xg13c2 PROC
X mov ax,[si] ; ax = -1234567 89abcd--
X shr ax,1 ; ax = --123456 789abcd-
X shr ax,1 ; ax = ---12345 6789abcd
X and ah,01fh ; mask junk
X inc si ; bump pointer
X mov cx,offset g13c3 ; point to next routine
X ret
Xg13c2 ENDP
X
X; g13c3 get 13 bit code 3: 1------- 11111111 ----1111
X
Xg13c3 PROC
X mov ax,[si] ; ax = 56789abc d-------
X inc si ; bump pointer
X inc si
X mov cl,[si] ; cl = ----1234
X and cl,00fh ; mask junk
X and al,080h ; mask junk
X or al,cl ; ax = 56789abc d---1234
X rol ax,1 ; ax = 6789abcd ---12345
X xchg ah,al ; ax = ---12345 6789abcd
X mov cx,offset g13c4 ; point to next routine
X ret
Xg13c3 ENDP
X
X; g13c4 get 13 bit code 4: 1111---- 11111111 -------1
X
Xg13c4 PROC
X mov ax,[si] ; ax = 23456789 abcd----
X inc si ; bump pointer
X inc si
X mov cl,[si] ; cl = ------1
X rcr cl,1 ; carry bit = 1
X rcr ax,1 ; ax = 12345678 9abcd---
X shr ax,1 ; ax = -1234567 89abcd--
X shr ax,1 ; ax = --123456 789abcd-
X shr ax,1 ; ax = ---12345 6789abcd
X mov cx,offset g13c5 ; point to next routine
X ret
Xg13c4 ENDP
X
X; g13c5 get 13 bit code 5: 1111111- --111111
X
Xg13c5 PROC
X mov ax,[si] ; ax = --123456 789abcd-
X shr ax,1 ; ax = ---12345 6789abcd
X and ah,01fh ; mask junk
X inc si
X mov cx,offset g13c6 ; point to next routine
X ret
Xg13c5 ENDP
X
X; g13c6 get 13 bit code 6: 11------ 11111111 -----111
X
Xg13c6 PROC
X mov ax,[si] ; ax = 456789ab cd------
X inc si
X inc si
X mov cl,[si] ; cl = -----123
X and al,0c0h ; mask junk
X and cl,007h ; mask junk
X or al,cl ; ax = 456789ab cd---123
X rol ax,1 ; ax = 56789abc d---1234
X rol ax,1 ; ax = 6789abcd ---12345
X xchg ah,al ; ax = ---12345 6789abcd
X mov cx,offset g13c7 ; point to next routine
X ret
Xg13c6 ENDP
X
X; g13c7 get 13 bit code 7: 11111--- 11111111
X
Xg13c7 PROC
X mov ax,[si] ; ax = 12345678 9abcd---
X shr ax,1 ; ax = -1234567 89abcd--
X shr ax,1 ; ax = --123456 789abcd-
X shr ax,1 ; ax = ---12345 6789abcd
X inc si ; bump pointer
X inc si
X mov cx,offset g13c0 ; synced, wrap around
X ret
Xg13c7 ENDP
X
X; ********************************************* 14 bit code extraction routines
X
X PUBLIC _init14
X_init14 PROC
X push bp
X mov bp,sp
X mov bx,[bp+4] ; bx points to codebuf struct
X mov cx,offset g14c0 ; initialize state to g14c0
X mov [bx],cx ; save new state routine
X pop bp
X ret
X_init14 ENDP
X
X; g14c0 get 14 bit code 0: 11111111 --111111
X
Xg14c0 PROC
X mov ax,[si] ; ax = --123456 789abcde
X and ah,03fh ; mask junk
X inc si ; bump pointer
X mov cx,offset g14c1 ; point to next routine
X ret
Xg14c0 ENDP
X
X; g14c1 get 14 bit code 1: 11------ 11111111 ----1111
X
Xg14c1 PROC
X mov ax,[si] ; ax = 56789abc de------
X inc si
X inc si
X mov cl,[si] ; cl = ----1234
X and al,0c0h ; mask junk
X and cl,00fh ; mask junk
X or al,cl ; ax = 56789abc de--1234
X rol ax,1 ; ax = 6789abcd e--12345
X rol ax,1 ; ax = 789abcde --123456
X xchg ah,al ; ax = --123456 789abcde
X mov cx,offset g14c2 ; point to next routine
X ret
Xg14c1 ENDP
X
X; g14c2 get 14 bit code 2: 1111---- 11111111 ------11
X
Xg14c2 PROC
X mov ax,[si] ; ax = 3456789a bcde----
X inc si
X inc si
X mov cl,[si] ; cl = ------12
X and al,0f0h ; mask junk
X and cl,003h ; mask junk
X or al,cl ; ax = 3456789a bcde--12
X ror ax,1 ; ax = 23456789 abcde--1
X ror ax,1 ; ax = 12345678 9abcde--
X shr ax,1 ; ax = -1234567 89abcde-
X shr ax,1 ; ax = --123456 789abcde
X mov cx,offset g14c3 ; point to next routine
X ret
Xg14c2 ENDP
X
X; g14c3 get 14 bit code 3: 111111-- 11111111
X
Xg14c3 PROC
X mov ax,[si] ; ax = 12345678 9abcde--
X shr ax,1 ; ax = -1234567 89abcde-
X shr ax,1 ; ax = --123456 789abcde
X inc si
X inc si
X mov cx,offset g14c4 ; point to next routine
X ret
Xg14c3 ENDP
X
X; g14c4 get 14 bit code 4: 11111111 --111111
X
Xg14c4 PROC ; same as 0
X mov ax,[si]
X and ah,03fh
X inc si
X mov cx,offset g14c5
X ret
Xg14c4 ENDP
X
X; g14c5 get 14 bit code 5: 11------ 11111111 ----1111
X
Xg14c5 PROC ; same as 1
X mov ax,[si]
X inc si
X inc si
X mov cl,[si]
X and al,0c0h
X and cl,00fh
X or al,cl
X rol ax,1
X rol ax,1
X xchg ah,al
X mov cx,offset g14c6
X ret
Xg14c5 ENDP
X
X; g14c6 get 14 bit code 6: 1111---- 11111111 ------11
X
Xg14c6 PROC ; same as 2
X mov ax,[si]
X inc si
X inc si
X mov cl,[si]
X and al,0f0h
X and cl,003h
X or al,cl
X ror ax,1
X ror ax,1
X shr ax,1
X shr ax,1
X mov cx,offset g14c7
X ret
Xg14c6 ENDP
X
X; g14c7 get 14 bit code 7: 111111-- 11111111
X
Xg14c7 PROC ; same as 3
X mov ax,[si]
X shr ax,1
X shr ax,1
X inc si
X inc si
X mov cx,offset g14c0 ; synced, wrap around
X ret
Xg14c7 ENDP
X
X; ********************************************* 15 bit code extraction routines
X
X PUBLIC _init15
X_init15 PROC
X push bp
X mov bp,sp
X mov bx,[bp+4] ; bx points to codebuf struct
X mov cx,offset g15c0 ; initialize state to g15c0
X mov [bx],cx ; save new state routine
X pop bp
X ret
X_init15 ENDP
X
X; g15c0 get 15 bit code 0: 11111111 -1111111
X
Xg15c0 PROC
X mov ax,[si] ; ax = -1234567 89abcdef
X and ah,07fh ; mask junk
X inc si
X mov cx,offset g15c1 ; point to next routine
X ret
Xg15c0 ENDP
X
X; g15c1 get 15 bit code 1: 1------- 11111111 --111111
X
Xg15c1 PROC
X mov ax,[si] ; ax = 789abcde f-------
X inc si
X inc si
X mov cl,[si] ; ax = --123456
X and al,080h ; mask junk
X and cl,03fh ; mask junk
X or al,cl ; ax = 789abcde f-123456
X rol ax,1 ; ax = 89abcdef -1234567
X xchg ah,al ; ax = -1234567 89abcdef
X mov cx,offset g15c2 ; point to next routine
X ret
Xg15c1 ENDP
X
X; g15c2 get 15 bit code 2: 11------ 11111111 ---11111
X
Xg15c2 PROC
X mov ax,[si] ; ax = 6789abcd ef------
X inc si
X inc si
X mov cl,[si] ; cl = ---12345
X and al,0c0h ; mask junk
X and cl,01fh ; mask junk
X or al,cl ; ax = 6789abcd ef-12345
X rol ax,1 ; ax = 789abcde f-123456
X rol ax,1 ; ax = 89abcdef -1234567
X xchg ah,al ; ax = -1234567 89abcdef
X mov cx,offset g15c3 ; point to next routine
X ret
Xg15c2 ENDP
X
X; g15c3 get 15 bit code 3: 111----- 11111111 ----1111
X
Xg15c3 PROC
X mov ax,[si] ; ax = 56789abc def-----
X inc si
X inc si
X mov cl,[si] ; cl = ----1234
X and al,0e0h
X and cl,00fh
X or al,cl ; ax = 56789abc def-1234
X rol ax,1 ; ax = 6789abcd ef-12345
X rol ax,1 ; ax = 789abcde f-123456
X rol ax,1 ; ax = 89abcdef -1234567
X xchg ah,al ; ax = -1234567 89abcdef
X mov cx,offset g15c4 ; point to next routine
X ret
Xg15c3 ENDP
X
X; g15c4 get 15 bit code 4: 1111---- 11111111 -----111
X
Xg15c4 PROC
X mov ax,[si] ; ax = 456789ab cdef----
X inc si
X inc si
X mov cl,[si] ; cl = -----123
X and cl,007h
X and al,0f0h
X or al,cl ; ax = 456789ab cdef-123
X ror ax,1 ; ax = 3456789a bcdef-12
X ror ax,1 ; ax = 23456789 abcdef-1
X ror ax,1 ; ax = 12345678 9abcdef-
X shr ax,1 ; ax = -1234567 89abcdef
X mov cx,offset g15c5 ; point to next routine
X ret
Xg15c4 ENDP
X
X; g15c5 get 15 bit code 5: 11111--- 11111111 ------11
X
Xg15c5 PROC
X mov ax,[si] ; ax = 3456789a bcdef---
X inc si
X inc si
X mov cl,[si] ; cl = ------12
X and al,0f8h
X and cl,003h
X or al,cl ; ax = 3456789a bcdef-12
X ror ax,1 ; ax = 23456789 abcdef-1
X ror ax,1 ; ax = 12345678 9abcdef-
X shr ax,1 ; ax = -1234567 89abcdef
X mov cx,offset g15c6 ; point to next routine
X ret
Xg15c5 ENDP
X
X; g15c6 get 15 bit code 6: 111111-- 11111111 -------1
X
Xg15c6 PROC
X mov ax,[si] ; ax = 23456789 abcdef--
X inc si
X inc si
X mov cl,[si] ; cl = -------1
X rcr cl,1 ; carry bit = 1
X rcr ax,1 ; ax = 12345678 9abcdef-
X shr ax,1 ; ax = -1234567 89abcdef
X mov cx,offset g15c7 ; point to next routine
X ret
Xg15c6 ENDP
X
X; g15c7 get 15 bit code 7: 1111111- 11111111
X
Xg15c7 PROC
X mov ax,[si] ; ax = 12345678 9abcdef-
X shr ax,1 ; ax = -1234567 89abcdef
X inc si
X inc si
X mov cx,offset g15c0 ; synced, wrap around
X ret
Xg15c7 ENDP
X
X; ********************************************** 16 bit code extraction routine
X
X PUBLIC _init16
X_init16 PROC
X push bp
X mov bp,sp
X mov bx,[bp+4] ; bx points to codebuf struct
X mov cx,offset g16c0 ; initialize state to g16c0
X mov [bx],cx ; save new state routine
X pop bp
X ret
X_init16 ENDP
X
X; g16c0 get 16 bit code 0: 11111111 11111111
X
Xg16c0 PROC
X mov ax,[si] ; get low & high bytes
X inc si ; skip past them
X inc si
X mov cx,offset g16c1 ; next routine
X ret
Xg16c0 ENDP
X
Xg16c1 PROC ; same as 0
X mov ax,[si]
X inc si
X inc si
X mov cx,offset g16c2
X ret
Xg16c1 ENDP
X
Xg16c2 PROC ; same as 0
X mov ax,[si]
X inc si
X inc si
X mov cx,offset g16c3
X ret
Xg16c2 ENDP
X
Xg16c3 PROC ; same as 0
X mov ax,[si]
X inc si
X inc si
X mov cx,offset g16c4
X ret
Xg16c3 ENDP
X
Xg16c4 PROC ; same as 0
X mov ax,[si]
X inc si
X inc si
X mov cx,offset g16c5
X ret
Xg16c4 ENDP
X
Xg16c5 PROC ; same as 0
X mov ax,[si]
X inc si
X inc si
X mov cx,offset g16c6
X ret
Xg16c5 ENDP
X
Xg16c6 PROC ; same as 0
X mov ax,[si]
X inc si
X inc si
X mov cx,offset g16c7
X ret
Xg16c6 ENDP
X
Xg16c7 PROC ; same as 0
X mov ax,[si]
X inc si
X inc si
X mov cx,offset g16c0 ; wrap back around
X ret
Xg16c7 ENDP
X
X END
END_OF_FILE
if test 24436 -ne `wc -c <'xcode.asm'`; then
echo shar: \"'xcode.asm'\" unpacked with wrong size!
fi
# end of 'xcode.asm'
fi
echo shar: End of archive 2 \(of 2\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked both archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
=====================================================================
usenet: tahorsley at ssd.harris.com USMail: Tom Horsley
compuserve: 76505,364 511 Kingbird Circle
genie: T.HORSLEY Delray Beach, FL 33444
======================== Aging: Just say no! ========================
More information about the Comp.sources.misc
mailing list