1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
; n2b_d8e.ash -- ucl_nrv2b_decompress_8 in 16-bit assembly (dos/exe)
;
; This file is part of the UCL real-time data compression library.
;
; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer
;
; The UCL library is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License as
; published by the Free Software Foundation; either version 2 of
; the License, or (at your option) any later version.
;
; The UCL library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with the UCL library; see the file COPYING.
; If not, write to the Free Software Foundation, Inc.,
; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
;
; Markus F.X.J. Oberhumer
; markus.oberhumer@jk.uni-linz.ac.at
; http://wildsau.idv.uni-linz.ac.at/mfx/ucl.html
;
; ------------- DECOMPRESSION -------------
; Input
; ds:si - source
; es:di - dest
; dx = ds
; cx = 0
; bx = 0x800F
; bp = 1
%ifndef jmps
%define jmps jmp short
%endif
%ifndef jmpn
%define jmpn jmp near
%endif
; __NRV2B16S__
literal_n2b:
movsb
decompr_start_n2b:
add bh, bh
jnz dec1_n2b
call reloadbh_n2b
dec1_n2b:
jc literal_n2b
inc cx
mov ax, es
%ifdef __NDIGT64K__
add di, di
jnc di_ok_n2b
add ah, 8
mov es, ax
di_ok_n2b:
shr di, 1
%endif; __NRV2BEX1__
offset_loop_n2b:
call getbit_cx_n2b
jcxz decomp_done_n2b
jnc offset_loop_n2b
dec cx
dec cx
jz offset_ok_n2b
%ifdef __N2BX8601__
add cx, cx
add cx, cx
add cx, cx
add cx, cx
%else; __N2B28601__
shl cx, 4
%endif; __NRV2BEX2__
mov bp, cx
mov bl, [si]
inc si
not bl
xor cx, cx
offset_ok_n2b:
call getbit_cx_n2b
adc cx, cx
jnz copy_match_n2b
inc cx
length_loop_n2b:
call getbit_cx_n2b
jnc length_loop_n2b
inc cx
inc cx
copy_match_n2b:
cmp bp, 0xd1
sbb cx, byte -2
sub ax, bp
jb handle_underflow_n2b
mov ds, ax
lea ax, [bx + di]
ds_ok_n2b:
sub ah, bh
xchg ax, si
rep
movsb
xchg ax, si
mov ds, dx
jmps decompr_start_n2b
handle_underflow_n2b:
%ifdef __N2BX8602__
shl ax, 1
shl ax, 1
shl ax, 1
shl ax, 1
push ax
xor ax, ax
mov ds, ax
pop ax
%else; __N2B28602__
shl ax, 4
push byte 0
pop ds
%endif; __NRV2BEX3__
add ax, bx
add ax, di
jmps ds_ok_n2b
getbit_cx_n2b:
add bh, bh
jnz gb2_n2b
call reloadbh_n2b
gb2_n2b:
adc cx, cx
getbit_n2b:
add bh, bh
jnz f2_n2b
reloadbh_n2b:
mov bh, [si]
%ifdef __NSIGT64K__
adc si, si
jnc si_ok_n2b
add dh, 8
mov ds, dx
si_ok_n2b:
shr si, 1
%endif; __NRV2BEX9__
inc si
adc bh, bh
f2_n2b:
ret
decomp_done_n2b:
; __NRV2B16E__
|