1/*
2;  n2b_d16.ash -- ucl_nrv2b_decompress_le16 in 16-bit assembly
3;
4;  This file is part of the UCL data compression library.
5;
6;  Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
7;  All Rights Reserved.
8;
9;  The UCL library is free software; you can redistribute it and/or
10;  modify it under the terms of the GNU General Public License as
11;  published by the Free Software Foundation; either version 2 of
12;  the License, or (at your option) any later version.
13;
14;  The UCL library is distributed in the hope that it will be useful,
15;  but WITHOUT ANY WARRANTY; without even the implied warranty of
16;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17;  GNU General Public License for more details.
18;
19;  You should have received a copy of the GNU General Public License
20;  along with the UCL library; see the file COPYING.
21;  If not, write to the Free Software Foundation, Inc.,
22;  59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23;
24;  Markus F.X.J. Oberhumer
25;  <markus@oberhumer.com>
26;  http://www.oberhumer.com/opensource/ucl/
27;
28
29
30; ------------- DECOMPRESSION -------------
31
32; Input
33; bx - 0x8000
34; cx - 0
35; si - source
36; di - dest
37; bp - -1
38*/
39
40#ifndef  COPY_MATCH
41# define COPY_MATCH     rep movsb
42#endif
43
44section         NRV2B160
45literal_n2b:
46                movsb
47decomp_start_n2b:
48                call    getbit_n2b
49                jcs     literal_n2b
50
51                inc     cx
52loop1_n2b:
53                call    getbit_cx_n2b
54section         NRVDDONE
55                jcxz    decomp_done_n2b
56section         NRVDRETU
57                jcxz    decomp_ret_n2b
58section         NRVDECO1
59                jnbs    loop1_n2b
60                sub     cx, 3
61                jbs     axbp_n2b
62                mov     ah, cl
63                lodsb
64                not     ax
65                xchg    bp, ax
66axbp_n2b:
67                xor     cx, cx
68                call    getbit_cx_n2b
69                adc     cx, cx
70                jnz     copy_match_n2b
71                inc     cx
72loop2_n2b:
73                call    getbit_cx_n2b
74                jnbs    loop2_n2b
75                inc     cx
76                inc     cx
77copy_match_n2b:
78section         NRVLED00
79                inc     cx
80section         NRVGTD00
81                cmp     bp, -0xd00
82                adc     cx, 1
83section         NRVDECO2
84                lea     ax, [bp+di]
85                xchg    ax, si
86                COPY_MATCH
87                xchg    ax, si
88                jmps    decomp_start_n2b
89getbit_cx_n2b:
90                call    getbit_n2b
91                adc     cx, cx
92getbit_n2b:
93                add     bx, bx
94                jnz     decomp_ret_n2b
95                lodsw
96                adc     ax, ax
97                xchg    ax, bx
98decomp_ret_n2b:
99                ret
100decomp_done_n2b:
101
102
103/*
104; =============
105; ============= 16-BIT CALLTRICK & JUMPTRICK
106; =============
107*/
108
109                cjt16   decomp_ret_n2b
110
111
112/* vim:set ts=4 et: */
113