1 ; basE91 encoder for DOS
\r
3 ; Copyright (c) 2005-2006 Joachim Henke
\r
4 ; All rights reserved.
\r
6 ; Redistribution and use in source and binary forms, with or without
\r
7 ; modification, are permitted provided that the following conditions are met:
\r
9 ; - Redistributions of source code must retain the above copyright notice,
\r
10 ; this list of conditions and the following disclaimer.
\r
11 ; - Redistributions in binary form must reproduce the above copyright notice,
\r
12 ; this list of conditions and the following disclaimer in the documentation
\r
13 ; and/or other materials provided with the distribution.
\r
14 ; - Neither the name of Joachim Henke nor the names of his contributors may
\r
15 ; be used to endorse or promote products derived from this software without
\r
16 ; specific prior written permission.
\r
18 ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
\r
19 ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
20 ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\r
21 ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
\r
22 ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
\r
23 ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
\r
24 ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
\r
25 ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
\r
26 ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
\r
27 ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
28 ; POSSIBILITY OF SUCH DAMAGE.
\r
35 mov si, ld_0 ; create lookup table
\r
56 cmp cl, 6 ; bits in queue + 8 < 14?
\r
73 and bh, 0x1F ; keep 13 bits
\r
76 cmp bx, byte 89 ; value in bit queue < 89?
\r
81 or bh, ah ; take 13 or 14 bits
\r
84 mov ax, [bx + a_ltab]
\r
89 shr bx, cl ; restore bit queue
\r
99 lea cx, [di - a_obuf]
\r
101 int 0x21 ; write to standard output
\r
108 int 0x21 ; read from standard input
\r
115 add bp, ax ; ax = 0 -> EOF
\r
122 cmp bx, byte 91 ; value in bit queue < 91?
\r
124 cmp cl, 8 ; less than 8 bits in queue?
\r
129 mov ax, [bx + a_ltab]
\r
135 int 0x21 ; write out 1 or 2 bytes
\r
137 retn ; exit program
\r
148 a_stck equ ((lc_2 - $$) + 256) & 510
\r
150 a_obuf equ ((ld_0 - $$) + 257) & 510
\r
151 s_ibuf equ ((a_ltab - a_obuf - 2) << 4) / 29
\r
152 a_ibuf equ a_ltab - s_ibuf
\r