Category : C Source Code
Archive   : LHA211S.ZIP
Filename : MAKETBL_.ASM

 
Output of file : MAKETBL_.ASM contained in archive : LHA211S.ZIP
;***********************************************
; maketbl_.asm -- makes decoding table
;***********************************************
page 0, 128

include amscls.inc
$_init GEN

TEXT segment byte public 'CODE'
TEXT ends

DATA segment word public 'DATA'
DATA ends

BSS segment word public 'DATA'
extrn nchar:word
extrn bitlen:word
extrn tablebits:word
extrn table:word
extrn avail_mt:word
extrn len_cnt:word
extrn start:word
extrn weight:word

extrn right_:word
extrn left_:word
extrn BROKENARC_:byte
extrn error_:near
BSS ends

DGROUP group DATA, BSS

TEXT segment byte public 'CODE'
assume cs:TEXT, ds:DGROUP
;---------------------------------------------------------------
; void make_table(short nchar, uchar bitlen[],
; ax bx
; short tablebits, ushort table[])
; cx dx
;---------------------------------------------------------------
public make_table_
make_table_ proc near
push cx
push dx
push si
push di
push bp

mov nchar, ax
shl ax, 1
mov avail_mt, ax
mov bitlen, bx
mov tablebits, cx
mov table, dx

push ds
pop es
cld

; /* clear len_cnt */
xor ax, ax
mov cx, 16
mov di, offset DGROUP:len_cnt + 2
rep stosw

; /* count bitlen into len_cnt */
xor bx, bx
mov cx, nchar
mov si, bitlen
$_do
mov bl, [si]
inc si
shl bx, 1
inc len_cnt[bx]
$_until

; /* initialize weight, start, table */
mov cx, tablebits
mov bp, 1
shl bp, cl
mov bx, offset DGROUP:len_cnt + 2
mov si, offset DGROUP:weight + 2
mov di, offset DGROUP:start + 2
mov ax, table
$_do
stosw
mov dx, [bx]
add bx, 2
shl dx, cl
add ax, dx
shr bp, 1
mov [si], bp
add si, 2
$_until
push ax
sub ax, table
mov cl, 15
sub cx, tablebits
shl ax, cl
shl bp, cl
$_do
stosw
mov dx, [bx]
add bx, 2
shl dx, cl
add ax, dx
mov [si], bp
add si, 2
dec cx
$_until , Z
$_if , NZ
mov ax, offset DGROUP:BROKENARC_
xor bx, bx
call error_
$_endif
pop di
mov ax, di
sub ax, table
shr ax, 1
mov bx, 1
mov cx, tablebits
shl bx, cl
mov cx, bx
sub cx, ax
xor ax, ax
rep stosw

; /* make table & additional tree */
xor ax, ax
$_do
mov si, ax
add si, bitlen
mov bl, [si]

or bl, bl
jz make_table_1
xor bh, bh

mov dx, bx
shl bx, 1
mov di, start[bx]
mov cx, weight[bx]
$_if , BE
rep stosw
mov start[bx], di
$_else
add start[bx], cx

mov si, di
mov bx, tablebits
mov cl, 16
sub cl, bl

shr di, cl
shl di, 1
add di, table

mov cl, bl
shl si, cl

xor cx, cx
mov cl, dl
sub cx, tablebits
; /* ‚‚³ n ‚Ì tree ‚ðì‚é */
$_do
$_if , E
; /* Ž}‚ª‚Ü‚¾‰„‚Ñ‚Ä‚¢‚È‚¯‚ê‚΍ì‚é */
mov bx, avail_mt
mov right_[bx], 0
mov left_[bx], 0
;; shr bx, 1
mov [di], bx
add avail_mt, 2
$_endif
mov di, [di]
;; shl di, 1
$_if , C
add di, offset DGROUP:right_
$_else
add di, offset DGROUP:left_
$_endif
$_until
mov [di], ax
$_endif
make_table_1:
inc ax
$_until , AE

pop bp
pop di
pop si
pop dx
pop cx
ret
make_table_ endp
TEXT ends
end


  3 Responses to “Category : C Source Code
Archive   : LHA211S.ZIP
Filename : MAKETBL_.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/