?? lzs.asm
字號:
mov bl, byte ptr DGROUP:_text_buf[di]
mov bh, 0 ;
call near ptr _EncodeChar
jmp short $_33
$_32:
add bx, 255 - THRESHOLD
call near ptr _EncodeChar
mov bx, DGROUP:_match_position
call near ptr _EncodePosition
$_33:
pop di ;
pop si ;
mov ax, word ptr DGROUP:_match_length
add word ptr DGROUP:_textsize, ax
adc word ptr DGROUP:_textsize + 2, 0
jmp short en03 ;
$_34:
call near ptr _InsertNode
en03: ;
call near ptr _DeleteNode
mov bx, DGROUP:_infile
getc_crc@ ;
or ax, ax
jS $_36
mov byte ptr DGROUP:_text_buf[si], al
cmp si, F - 1
jAE $_37
mov DGROUP:_text_buf[si + N], al
$_37:
jmp short $_38
$_36:
dec word ptr len
$_38:
inc si ;
inc di ;
and si, N - 1 ;
and di, N - 1 ;
dec _match_length
jNZ $_34
$_35:
call near ptr _MatchInsertNode
cmp len, 0
jLE $_39
jmp $_29
$_30:
$_39:
call near ptr _EncodeEnd ;
;
mov es, DGROUP:extra ;
mov ah, 49h ; release memory
int 21h ;
en05: ;
pop bp ;
pop di ;
pop si ;
ret ;
_Encode endp ;
;
;-----------------------------------------------;
; LZHUF 偺 decode ;
;-----------------------------------------------;
public _Decode ;
_Decode proc near ;
push si ;
push di ;
push bp ;
mov ax, word ptr DGROUP:_textsize ;
or ax, word ptr DGROUP:_textsize+2 ;
jNZ $_40
jmp de9 ;
$_40:
call near ptr _StartModel ;
call near ptr InitBuf ;
mov di, N - F ;
$_41:
push di ;
call near ptr _DecodeChar ;
mov di, ax ;
cmp ax, 256
jGE $_43
pop di ;
mov bx, word ptr DGROUP:_outfile
putc_crc@ ;
mov byte ptr DGROUP:_text_buf[di], al
inc di ;
and di, N - 1 ;
sub DGROUP:_textsize, 1
sbb DGROUP:_textsize + 2, 0
jmp short $_44
$_43:
call near ptr _DecodePosition
mov cx, di ;
pop di ;
mov si, di ;
sub si, ax ;
dec si ;
and si, N - 1 ;
sub cx, 255 - THRESHOLD
sub DGROUP:_textsize, cx
sbb DGROUP:_textsize + 2, 0
mov dx, DGROUP:_outfile
$_45:
mov al, DGROUP:_text_buf[si]
mov DGROUP:_text_buf[di], al
inc si ;
inc di ;
and si, N - 1
and di, N - 1
mov bx, dx ;
putc_crc@ ;
LOOP $_45
$_46:
$_44:
mov ax, word ptr DGROUP:_textsize+2
or ax, ax
jS $_47
or ax, word ptr DGROUP:_textsize
jZ $_47
jmp $_41
$_42:
$_47:
de9: ;
call crcend ;
pop bp ;
pop di ;
pop si ;
ret ;
_Decode endp ;
;
;-----------------------------------------------;
; LArc type 5 偺 decode ;
;-----------------------------------------------;
public _DecodeOld ;
_DecodeOld proc near ;
push si ;
push di ;
push bp ;
push ds ;
pop es ;
mov ax, word ptr DGROUP:_textsize ;
or ax, word ptr DGROUP:_textsize+2 ;
jNZ $_48
jmp do9 ;
$_48:
call near ptr InitBuf ;
mov di, N - F_OLD ;
mov dl, 80h ;
$_49:
rol dl, 1
jNC $_51
mov bx, word ptr DGROUP:_infile
getc@ ;
mov dh, al ;
$_51:
mov bx, word ptr DGROUP:_infile
getc@ ;
test dh, dl
jZ $_52
mov bx, word ptr DGROUP:_outfile
putc_crc@ ;
mov byte ptr DGROUP:_text_buf[di], al
inc di ;
and di, N - 1 ;
sub DGROUP:_textsize, 1
sbb DGROUP:_textsize + 2, 0
jmp short $_53
$_52:
mov cl, al ;
mov bx, word ptr DGROUP:_infile
getc@ ;
mov ch, al ;
shr ch, 1 ;
shr ch, 1 ;
shr ch, 1 ;
shr ch, 1 ;
mov si, cx ;
and ax, 000fh ;
add ax, 3 ;
mov cx, ax ;
sub DGROUP:_textsize, cx
sbb DGROUP:_textsize + 2, 0
$_54:
mov al, DGROUP:_text_buf[si]
mov DGROUP:_text_buf[di], al
mov bx, DGROUP:_outfile
putc_crc@ ;
inc si ;
inc di ;
and si, N - 1
and di, N - 1
LOOP $_54
$_55:
$_53:
mov ax, word ptr DGROUP:_textsize+2
or ax, ax
jS $_56
or ax, word ptr DGROUP:_textsize
jZ $_56
jmp $_49
$_50:
$_56:
do9: ;
call crcend ;
pop bp ;
pop di ;
pop si ;
ret ;
_DecodeOld endp ;
;
;-----------------------------------------------;
; sub-module for ;
; calculate CRC in buffer ;
;-----------------------------------------------;
; ax = _crc ;
; cx = length ;
; si = buffer ;
;-----------------------------------------------;
MAXBLK equ 64 ;
;
public crcsub ;
crcsub proc near ;
jcxz crcsub9 ;
mov ax, DGROUP:_curcnt ;
inc DGROUP:_curcnt ;
cmp ax, DGROUP:_nxtcnt
jB $_57
push bx ;
push dx ;
push cx ;
push ax ;
mov ah, 40h ; output char to stderr
mov bx, 2 ;
mov cx, 1 ;
mov dx, offset DGROUP:mark ;
int 21h ;
pop ax ;
pop cx ;
cmp DGROUP:_blkcnt, MAXBLK
jBE $_58
mov bx, MAXBLK ; calculation of next blk
mul bx ;
mov bx, DGROUP:_blkcnt
dec bx ;
add ax, bx ;
adc dx, 0 ;
inc bx ;
div bx ;
inc ax ;
mul bx ;
mov bx, MAXBLK ;
div bx ;
jmp short $_59
$_58:
inc ax ;
$_59:
mov DGROUP:_nxtcnt, ax ;
pop dx ;
pop bx ;
$_57:
mov ax, DGROUP:_crc ;
push bx ;
$_60:
xor al, [si] ;
inc si ;
mov bl, al ; crc & 0xff
xor bh, bh ;
mov al, ah ; crc >> 8
xor ah, ah ;
shl bx, 1 ;
xor ax, crctbl[bx] ;
LOOP $_60
$_61:
pop bx ;
mov DGROUP:_crc, ax ;
crcsub9: ;
ret ;
crcsub endp ;
;
;-----------------------------------------------;
; get CRC for putc in buffer ;
;-----------------------------------------------;
public crcbuf ;
crcbuf proc near ;
push cx ;
push si ;
mov cx, 10[bx] ;
mov si, 8[bx] ;
sub cx, si ;
mov bl, 4[bx] ;
call crcsub ;
pop si ;
pop cx ;
ret ;
crcbuf endp ;
;
;-----------------------------------------------;
; end process of CRC for putc ;
;-----------------------------------------------;
public crcend ;
crcend proc near ;
mov bx, DGROUP:_outfile ;
test word ptr 2[bx], 0200h
jZ $_62
cmp byte ptr 4[bx], 01h
jE $_63
$_62:
call crcbuf ;
$_63:
ret ;
crcend endp ;
;
;-----------------------------------------------;
; CRC & putc ;
;-----------------------------------------------;
public crcputc ;
crcputc proc near ;
push bx ;
push ax ;
test word ptr 2[bx], 0200h
jZ $_64
cmp byte ptr 4[bx], 01h
jE $_65
$_64:
call crcbuf ;
jmp short $_66
$_65:
xor al, byte ptr DGROUP:_crc;
mov bl, al ;
xor bh, bh ;
shl bx, 1 ;
mov ax, crctbl[bx] ;
xor al, byte ptr DGROUP:_crc + 1
mov DGROUP:_crc, ax ;
$_66:
pop ax ;
pop bx ;
cmp DGROUP:_tstflg, 0
jE $_67
push cx ;
push bx ;
mov cx, 6[bx] ;
neg cx ;
mov [bx], cx ;
mov cx, 8[bx] ;
inc cx ;
mov 10[bx], cx ;
mov bx, cx ;
mov [bx - 1], al ;
pop bx ;
pop cx ;
ret ;
$_67:
;
public fputc ;
fputc proc near ;
push dx ;
push cx ;
push bx ;
push ax ;
call __fputc ;
inc sp ;
inc sp ;
pop bx ;
or ax, ax
jNS $_68
push DGROUP:_outfname ;
mov ax, 14 ; WTERR
push ax ;
call near ptr _error ;
$_68:
pop cx ;
pop dx ;
ret ;
fputc endp ;
crcputc endp ;
;
;-----------------------------------------------;
; CRC & getc ;
;-----------------------------------------------;
public crcgetc ;
crcgetc proc near ;
push dx ;
push cx ;
push bx ;
call __fgetc ;
pop bx ;
or ax, ax
jS $_69
push si ;
push ax ;
mov si, 8[bx] ;
mov cx, [bx] ;
inc cx ;
call crcsub ;
pop ax ;
pop si ;
$_69:
pop cx ;
pop dx ;
ret ;
crcgetc endp ;
;
;-----------------------------------------------;
; make CRC table ;
;-----------------------------------------------;
public _mkcrc ;
_mkcrc proc near ;
mov bx, offset DGROUP:crctbl ;
xor dx, dx ;
$_70:
mov ax, dx ;
mov cx, 8 ;
$_72:
shr ax, 1
jNC $_74
xor ax, 0a001h
$_74:
LOOP $_72
$_73:
mov [bx], ax ;
inc bx ;
inc bx ;
inc dl
jNZ $_70
$_71:
ret ;
_mkcrc endp ;
;
;-----------------------------------------------;
; get CRC for _copyfile ;
;-----------------------------------------------;
public _getcrc ;
_getcrc proc near ;
push si ;
push cx ;
mov si, offset DGROUP:_buf2 ;
call crcsub ;
pop cx ;
pop si ;
ret ;
_getcrc endp ;
;
;-----------------------------------------------;
; 崅懍僐僺乕 ;
;-----------------------------------------------;
; void copyfile(FILE *f0, FILE *f1, long size) ;
;-----------------------------------------------;
public _copyfile ;
_copyfile proc near ;
__f0 = 4 ;
__f1 = 6 ;
__size = 8 ;
push bp ;
mov bp, sp ;
mov DGROUP:_crc, 0 ;
mov ax, __size[bp] ;
or ax, __size + 2[bp] ;
jNZ $_75
jmp cf9 ;
$_75:
;
push si ;
push di ;
mov si, __f0[bp] ;
mov di, __f1[bp] ;
;
push si ;
call _ftell ;
pop cx ;
mov cx, dx ;
mov dx, ax ;
mov bl, 4[si] ;
xor bh, bh ;
mov si, bx ; fd0
mov ax, 4200h ;
int 21h ; lseek
;
push di ;
call _ftell ;
pop cx ;
mov cx, dx ;
mov dx, ax ;
mov bl, 4[di] ;
xor bh, bh ;
mov di, bx ; fd1
mov ax, 4200h ;
int 21h ; lseek
;
mov dx, offset DGROUP:_buf2 ;
$_76:
mov cx, 0a000h ;
cmp DGROUP:_crcflg, 0
jE $_78
mov cx, 01000h ;
$_78:
cmp word ptr __size + 2[bp], 0
jNZ $_79
cmp cx, __size[bp]
jBE $_79
mov cx, __size[bp] ;
$_79:
mov bx, si ;
mov ah, 3fh ;
int 21h ;
jC $_80
cmp ax, cx
jE $_81
$_80:
push DGROUP:_infname ;
mov ax, 13 ; RDERR
push ax ;
call _error ;
$_81:
cmp DGROUP:_tstflg, 0
jNE $_82
mov bx, di ;
mov ah, 40h ;
int 21h ;
jC $_83
dec bx ; STDOUT ?
jne cf1 ;
mov ax, cx ;
cf1: ;
inc bx ;
cmp ax, cx
jE $_84
$_83:
push DGROUP:_outfname
mov ax, 14 ; WTERR
push ax ;
call _error ;
$_84:
$_82:
sub __size[bp], ax ;
sbb word ptr __size + 2[bp], 0
cmp DGROUP:_crcflg, 0
jE $_85
call _getcrc ;
$_85:
mov ax, __size[bp] ;
or ax, __size + 2[bp] ;
jNZ $_76
$_77:
;
xor cx, cx ;
mov bx, di ;
mov ah, 40h ; to abandon rest of old file
int 21h ;
;
push cx ;
mov dx, cx ;
mov bx, si ;
mov ax, 4201h ; lseek
int 21h ;
push dx ;
push ax ;
push word ptr __f0[bp] ;
call near ptr _fseek ;
add sp, 8 ;
;
xor cx, cx ;
push cx ;
mov dx, cx ;
mov bx, di ;
mov ax, 4201h ; lseek
int 21h ;
push dx ;
push ax ;
push word ptr __f1[bp] ;
call near ptr _fseek ;
add sp, 8 ;
;
pop di ;
pop si ;
cf9: ;
pop bp ;
ret ;
_copyfile endp ;
;
_TEXT ends ;
end ;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -