home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 June
/
SIMTEL_0692.cdr
/
msdos
/
filutl
/
ldiff12s.arc
/
LDE16.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-07-15
|
9KB
|
370 lines
;-----------------------------------------------------------------------------;
; LDE16.asm ĽÅæî┼ÆΦÄ«üiùΓôÇüj (C) ÄOû╪ÿaòF NIFTY SDR SDI00147 1989/7/15;
;-----------------------------------------------------------------------------;
; ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ èεû{ôIé╚âAâïâSâèâYâÇé═ë£æ║Äüé╠ébé≡ÄQÅ╞;
; ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ ü@ü@ü@ü@ ì\æóë╗â}âNâìé═î├É∞Äüé╠éαé╠é≡Ägùp;
; ;
; ì∞ɼû@: ;
; optasm é≡ Use THREADs for Smaller OBJ(N) é╔é╡é─âAâZâôâuâïé╖éΘ ;
; ;
;-----------------------------------------------------------------------------;
include lms3.inc ; ìéæ¼ì\æóë╗â}âNâì
; (c)S.Furukawa
include minimac.inc ; movseg movdat movdatb
;-----------------------------------------------------------------------------;
data segment word public ;
extrn WBuff : byte ; Åæì₧é▌âoâbâtâ@
extrn CrcTable : word ; éâéÆéâùpâeü[âuâï
extrn CRC : word ; éâéÆéâ
extrn DicSeg : word ; ĽÅæâoâbâtâ@
;
SrcSeg dw ? ;
WPoint dw ? ; Åæì₧é▌â|âCâôâ^
InHandle dw ? ; ôⁿù═ânâôâhâï
OutHandle dw ? ; Åoù═ânâôâhâï
PushSp dw ? ; éôéÉæ▐ö≡ùpâÅü[âN
SrcSize dw ? ; âtâ@âCâïâTâCâY
DicSize dw ? ;
CodeBuf db 33 dup(?) ; éWârâbâgùpâÅü[âN
CmpLen dw ? ;
SBufLen dw ? ;
CPoint dw ? ;
SftFlg db ? ;
MatchLen dw ? ;
MatchAdr dw ? ;
BCD dw ? ;
BCD2 dw ? ;
BCDSTR db 14 dup(?) ;
;
MINWORD equ 3 ;
MAXWORD equ 0ffffh ;
data ends ;
;
code segment byte public ;
assume cs:code,ds:data,es:data ;
;
public EnCode16 ;
;
WBUFFEND equ 0fffh ;
;
;-------------------------------------------------------;
; ïñÆ╩âîâWâXâ^ò╧Éö ;
; ---------------- ;
; ds:[si] â\ü[âXâ|âCâôâ^ ;
;-------------------------------------------------------;
BEGIN CodeFlush ;
mov cx,CPoint ;
mov bx,offset CodeBuf ;
sub cx,bx ;
mov di,WPoint ;
.do ;
mov al,[bx] ;
inc bx ;
.if <di a WBUFFEND> ;
pushm ax,bx,cx ;
mov dx,offset WBuff ;
mov cx,di ;
mov bx,OutHandle ;
msdos 40h ;
jc ErrOut ;
cmp ax,cx ;
jne ErrOut ;
popm cx,bx,ax ;
xor di,di ;
.endif ;
mov WBuff[di],al ;
inc di ;
.loop ;
mov WPoint,di ;
mov SftFlg,1 ;
mov CodeBuf,0 ;
mov CPoint,(offset CodeBuf)+1 ;
ret ;
ENDN CodeFlush ;
;-------------------------------------------------------;
; âfü[â^Åoù═ ;
; ---------- ;
; in cx ôKìçÆ╖ ;
; des -- ;
;-------------------------------------------------------;
BEGIN OutPut ;
push cx ;
dec cx ;
mov bx,CPoint ;
.if <z> ;
push ds ;
mov ds,SrcSeg ;
mov al,[si] ;
pop ds ;
mov [bx],al ;
inc bx ;
mov al,SftFlg ;
or CodeBuf,al ;
.else ;
sub cx,3 ;
mov ax,MatchAdr ;
mov [bx],ax ;
inc bx ;
inc bx ;
mov [bx],cx ;
inc bx ;
inc bx ;
.endif ;
mov CPoint,bx ;
shl SftFlg,1 ;
.if <c> ;
call CodeFlush ;
.endif ;
pop cx ;
ret ;
ENDN OutPut ;
;-------------------------------------------------------;
; ébéqébîvÄZ ;
; ---------- ;
; in cx,dx ;
; out -- ;
; des -- ;
;-------------------------------------------------------;
BEGIN CrcCalc ;
.if <cxnz> ;
pushm es,si,dx,cx,bx,ax ;
mov es,SrcSeg ;
mov si,dx ;
mov dx,CRC ;
.do ;
mov al,es:[si] ;
inc si ;
mov bl,dl ;
xor bh,bh ;
xor bl,al ;
shl bx,1 ;
mov ax,CrcTable[bx] ;
mov bl,dh ;
xor bh,bh ;
xor bx,ax ;
mov dx,bx ;
.loop ;
mov CRC,dx ;
popm ax,bx,cx,dx,si,es ;
.endif ;
ret ;
ENDN CrcCalc ;
;-------------------------------------------------------;
; âfü[â^ô╟é▌ì₧é▌ ;
; -------------- ;
; in cx ;
;-------------------------------------------------------;
BEGIN ReSetBuf ;
add si,cx ;
sub SBufLen,cx ;
mov ax,SBufLen ;
.if <ax b CmpLen> ;
mov CmpLen,ax ;
.endif ;
ret ;
ENDN ReSetBuf ;
;-------------------------------------------------------;
; îƒì⌡ SI --> CX
;-------------------------------------------------------;
BEGIN Search ;
mov es,DicSeg ;
xor di,di ;
mov MatchLen,MINWORD ;
.if <CmpLen be MINWORD> ;
jmp #out ;
.endif ;
mov cx,DicSize ;
.do ;
push ds ;
mov ds,SrcSeg ;
mov al,[si] ;
pop ds ;
.do ;
.if <cx be MINWORD> ;
jmp #out ;
.endif ;
or cx,cx ;
repnz scasb ;
.enddo <nz> ;
.break <cx be MatchLen> ;
pushm cx,si,di ;
inc cx ;
.if <cx a CmpLen> ;
mov cx,CmpLen ;
.endif ;
dec di ;
mov dx,di ;
mov bx,cx ;
xor al,al ;
push ds ;
mov ds,SrcSeg ;
repz cmpsb ;
pop ds ;
.if <z> ;
popm di,si,ax ;
mov MatchLen,bx ;
mov MatchAdr,dx ;
.break ;
.endif ;
sub bx,cx ;
dec bx ;
.if <bx a MatchLen> ;
mov MatchLen,bx ;
mov MatchAdr,dx ;
.endif ;
popm di,si,cx ;
.enddo <> ;
#out: mov cx,MatchLen ;
.if <cx be MINWORD> ;
mov cx,1 ;
.endif ;
ret ;
ENDN Search ;
;-------------------------------------------------------;
; âJâEâôâgò\Ī CX
;-------------------------------------------------------;
BEGIN Display ;
push cx ;
.if <cx e 1> ;
mov ax,BCD ;
inc al ;
daa ;
xchg ah,al ;
adc al,0 ;
daa ;
xchg ah,al ;
mov BCD,ax ;
and ax,0f0fh ;
or ax,3030h ;
mov BCDSTR[3],ah ;
mov BCDSTR[5],al ;
mov ax,BCD ;
mov cl,4 ;
shr ax,cl ;
and ax,0f0fh ;
or ax,3030h ;
mov BCDSTR[2],ah ;
mov BCDSTR[4],al ;
.else ;
mov ax,BCD2 ;
inc al ;
daa ;
xchg ah,al ;
adc al,0 ;
daa ;
xchg ah,al ;
mov BCD2,ax ;
and ax,0f0fh ;
or ax,3030h ;
mov BCDSTR[10],ah ;
mov BCDSTR[12],al ;
mov ax,BCD2 ;
mov cl,4 ;
shr ax,cl ;
and ax,0f0fh ;
or ax,3030h ;
mov BCDSTR[9],ah ;
mov BCDSTR[11],al ;
.endif ;
mov bx,2 ;
mov cx,14 ;
mov dx,offset BCDSTR ;
msdos 40h ;
pop cx ;
ret ;
ENDN Display ;
;-------------------------------------------------------;
; Åëè·ë╗ --> SI
;-------------------------------------------------------;
BEGIN Init ;
mov BCD,1 ;
mov BCD2,1 ;
mov BCDSTR,CR ;
mov BCDSTR[1],'(' ;
mov BCDSTR[2],'0' ;
mov BCDSTR[3],'0' ;
mov BCDSTR[4],'0' ;
mov BCDSTR[5],'0' ;
mov BCDSTR[6],')' ;
mov BCDSTR[7],'-' ;
mov BCDSTR[8],'(' ;
mov BCDSTR[9],'0' ;
mov BCDSTR[10],'0' ;
mov BCDSTR[11],'0' ;
mov BCDSTR[12],'0' ;
mov BCDSTR[13],')' ;
;-------------------------------------------------------;
movdat SrcSeg,DicSeg ;
add SrcSeg,1000h ;
.if <DicSize b MAXWORD> ;
movdat CmpLen,DicSize ;
.else ;
mov CmpLen,MAXWORD ;
.endif ;
movdat SBufLen,SrcSize ;
;-------------------------------------------------------;
mov cx,SrcSize ;
mov bx,InHandle ;
xor dx,dx ;
push ds ;
mov ds,SrcSeg ;
msdos 3fh ;
pop ds ;
jc ErrOut ;
cmp ax,cx ;
jne ErrOut ;
call CrcCalc ;
mov ax,SBufLen ;
.if <ax b CmpLen> ;
mov CmpLen,ax ;
.endif ;
;-------------------------------------------------------;
mov SftFlg,1 ;
mov CodeBuf,0 ;
mov CPoint,(offset CodeBuf)+1 ;
mov WPoint,0 ;
xor si,si ;
ret ;
ret ;
ENDN Init ;
;-----------------------------------------------------------------------------;
; EnCode64(in:word,out:word;dicsize,size:longint):boolean ;
;-----------------------------------------------------------------------------;
BEGIN EnCode16 ;
cld ;
mov bx,sp ;
mov PushSp,sp ;
movdat InHandle ,ss:[bx+12] ;
movdat OutHandle ,ss:[bx+10] ;
movdat DicSize ,ss:[bx+6] ;
movdat SrcSize ,ss:[bx+2] ;
call Init ;
.while <CmpLen ne 0> ;
call Search ;
call Display ;
call OutPut ;
call ResetBuf ;
.enddo ;
.if <SftFlg ne 1> ;
call CodeFlush ;
.endif ;
mov dx,offset WBuff ;
mov bx,OutHandle ;
mov cx,WPoint ;
jcxz NrmOut ;
msdos 40h ;
jc ErrOut ;
cmp ax,cx ;
je NrmOut ;
ErrOut: xor ax,ax ;
jmp OutPro ;
NrmOut: mov ax,1 ;
OutPro: mov sp,PushSp ;
ret 12 ;
ENDN EnCode16 ;
;
;
code ends ;
end ;
;------------------------------------------------------------------------------