home *** CD-ROM | disk | FTP | other *** search
- page ,132
- title dc ( dircomp - compare 2 dirs ) as of 01/21/87 - 10:45 pm
- ;*-------------------------------------------------
- ;
- ; dircomp.asm
- ; lists two directories side by side
- ;
- ;*-------------------------------------------------
- codeseg segment
- ;
- assume cs:codeseg,ds:codeseg,es:codeseg,ss:codeseg
- ;
- org 128
- ;
- param label byte
- ;
- org 256
- ;
- entry: jmp begin
- ;
- ;*-------------------------------------------------------
- ; most of the data is here; but some is at the end
- ;*-------------------------------------------------------
- ;
- synmsg db 'syntax: dc filespec filespec$'
- dosmsg db 'dc: Needs dos 2.0 + $'
- bfnmsg db 'dc: Bad file name $'
- tmfmsg db 'dc: Too many files $'
- nemmsg db 'dc: Not enough memory $'
- ;
- tosm db 'name.... ext size date.... time '
- db 'name.... ext size date.... time ',13,10,'$'
- ;
- coqm db 13,10,'===> press enter to continue ! $'
- ;
- delim db 9,' ,;='
- ;
- filist1 dd 0,0
- filist2 dd 0,0
- filcnt1 dw 0
- filcnt2 dw 0
- ;
- append db '\*.*',0
- ;
- slc db 0
- ;
- ; check dos version
- ;
- begin: mov ah,48
- int 33
- cmp al,2
- jae dosok
- lea dx,dosmsg
- errexit:
- mov ah,9
- int 33
- int 32
- ;
- ; parse command line to get filespecs
- ;
- dosok:
- cld
- lea si,param
- lodsb
- mov bl,al
- sub bh,bh
- mov word ptr [si + bx],0d20h
- lea di,filspec1
- call gfs
- lea di,filspec2
- call gfs
- ;
- ; de- allocate rest of memory
- ;
- lea dx,nemmsg
- lea sp,stacktop
- mov bx,sp
- add bx,15
- mov cl,4
- shr bx,cl
- mov ah,74
- int 33
- jc errexit
- ;
- ; find files from filespecs
- ;
- lea dx,dtabfr
- mov ah,26
- int 33
- ;
- lea dx,filspec1
- call gfas
- mov word ptr [filist1 + 2],ax
- mov [filcnt1],cx
- ;
- lea dx,filspec2
- call gfas
- mov word ptr [filist2 + 2],ax
- mov [filcnt2],cx
- call tos
- ;
- ; now display on screen
- ;
- ndos:
- lea di,dspstr
- mov al,32
- cmp [filcnt1],0
- jz fcd
- cmp [filcnt2],0
- jz lo1
- push si
- push di
- push ds
- push es
- les di,[filist2]
- lds si,[filist1]
- mov cx,12
- repz cmpsb
- pop es
- pop ds
- pop di
- pop si
- jb lo1
- ja lo2
- call lf1
- stosb
- jmp dosec
- ;
- ; first column done
- ;
- fcd:
- cmp [filcnt2],0
- jz alldone
- ;
- ; list only 2
- ;
- lo2:
- mov cx,40
- rep stosb
- ;
- ; do second
- ;
- dosec:
- call lf2
- jmp wcl
- ;
- ; list only 1
- ;
- lo1:
- call lf1
- mov cx,40
- rep stosb
- ;
- ; write cr, lf
- ;
- wcl:
- mov ax,0a0dh
- stosw
- ;
- ; spill out
- ;
- so:
- lea dx,dspstr
- mov cx,81
- mov bx,1
- mov ah,64
- int 33
- inc slc
- cmp slc,20
- jb jndos
- call scoqm
- call tos
- jndos:
- jmp ndos
- ;
- alldone:
- int 32
- ;*-------------------------------------
- ;* get file spec
- ;* uses di to point to destination
- ;*-------------------------------------
- gfs:
- mov dx,di
- search:
- call scanparm
- je search
- searche:
- stosb
- call scanparm
- jne searche
- mov byte ptr [di],0
- push si
- mov si,1+offset append
- mov cx,4
- cmp byte ptr [di-1],':'
- jz appends
- cmp byte ptr [di-1],'\'
- jz appends
- mov ax,4300h
- int 33
- jc fud
- test cl,16
- jz fud
- dec si
- inc cx
- ;
- appends:
- rep movsb
- fud:
- pop si
- ret
- ;
- ; scan parameter
- ;
- scanparm:
- push di
- lodsb
- cmp al,13
- jne naend
- lea dx,synmsg
- jmp errexit
- naend:
- lea di,delim
- mov cx,5
- repne scasb
- pop di
- ret
- ;
- ; get files and sort
- ;
- gfas:
- push es
- mov bx,1000h
- mov ah,48h
- int 33
- jnc allok
- mov ah,48
- int 33
- allok:
- mov cl,4
- shl bx,cl
- sub bx,20
- mov es,ax
- sub di,di
- sub bp,bp
- mov cx,6
- mov ah,4eh
- findfile:
- int 33
- jnc continue
- cmp ax,18
- jz nomofils
- lea dx,bfnmsg
- jmp errexit
- continue:
- cmp di,bx
- jb stillok
- tmf:
- lea dx,tmfmsg
- jmp errexit
- stillok:
- inc bp
- mov si,30+offset dtabfr
- mov cx,12
- traname:
- lodsb
- or al,al
- jz namedone
- cmp al,'.'
- jnz noperiod
- sub cx,3
- mov al,32
- rep stosb
- add cx,3
- jmp traname
- noperiod:
- stosb
- loop traname
- namedone:
- mov al,32
- rep stosb
- mov si,22+offset dtabfr
- mov cx,4
- rep movsw
- mov ah,4fh
- jmp findfile
- nomofils:
- mov bx,di
- add bx,15
- mov cl,4
- shr bx,cl
- mov ah,4ah
- int 33
- ;
- ;* sort files
- ;
- push ds
- push es
- pop ds
- sub di,di
- mov cx,bp
- jcxz sad
- dec cx
- jcxz sad
- sortlp1:
- push cx
- mov si,di
- sortlp2:
- add si,20
- push cx
- push si
- push di
- mov cx,20
- repz cmpsb
- jae nosw
- pop di
- pop si
- push si
- push di
- mov cx,20
- swloop:
- mov al,es:[di]
- movsb
- mov ds:[si-1],al
- loop swloop
- nosw:
- pop di
- pop si
- pop cx
- loop sortlp2
- pop cx
- add di,20
- loop sortlp1
- sad:
- pop ds
- mov ax,es
- pop es
- mov cx,bp
- ret
- ;
- ;* list files on screen
- ;
- lf1:
- push ds
- lds si,[filist1]
- call listfile
- pop ds
- mov word ptr[filist1],si
- dec [filcnt1]
- ret
- lf2:
- push ds
- lds si,[filist2]
- call listfile
- pop ds
- mov word ptr[filist2],si
- dec [filcnt2]
- ret
- listfile:
- push ax
- push si
- push di
- mov cx,12
- rep movsb
- mov al,32
- mov cx,27
- rep stosb
- sub di,6
- lodsw
- ;
- mov bl,01fh
- mov bh,'0'
- mov cl,11
- sub dl,dl
- mov dh,':'
- call datime
- ;
- mov bx,3fh
- mov cl,5
- mov dh,32
- call datime
- ;
- sub di,16
- lodsw
- ;
- mov bl,0fh
- mov bh,'0'
- mov cl,5
- mov dh,'-'
- call datime
- ;
- mov bx,1fh
- mov cl,0
- call datime
- ;
- mov bl,7fh
- mov cl,9
- mov dl,80
- mov dh,32
- call datime
- sub di,12
- lodsw
- mov dx,ax
- lodsw
- mov bx,10
- std
- ascloop:
- mov cx,dx
- sub dx,dx
- div bx
- xchg ax,cx
- div bx
- xchg ax,dx
- add al,'0'
- stosb
- mov ax,cx
- or cx,dx
- jnz ascloop
- ;
- cld
- pop di
- pop si
- pop ax
- add si,20
- add di,39
- ret
- ;
- ; date and time display
- ;
- datime:
- push ax
- push bx
- push cx
- push dx
- ;
- shr ax,cl
- and al,bl
- add al,dl
- sub ah,ah
- mov bl,10
- div bl
- add ax,'00'
- cmp al,bh
- jnz lnz
- mov al,32
- lnz:
- stosw
- mov al,dh
- stosb
- pop dx
- pop cx
- pop bx
- pop ax
- ret
- ;
- ; top of screen
- ;
- tos:
- mov ah,11
- mov bh,0
- mov bl,6
- int 16
- mov ah,2
- mov bh,0
- mov dh,0
- mov dl,0
- int 16
- mov ah,9
- mov al,32
- mov bh,0
- mov bl,110
- mov cx,4000
- int 16
- lea dx,tosm
- mov ah,9
- int 33
- mov slc,0
- ret
- ;
- ; send cont or quit msg
- ;
- scoqm:
- lea dx,coqm
- mov ah,9
- int 33
- mov ah,7
- int 33
- ret
- ;
- ; variable length data stored here
- ;
- even
- ;
- filspec1 label byte
- ;
- filspec2 equ filspec1 + 80
- ;
- dtabfr equ filspec2 + 80
- ;
- dspstr equ dtabfr + 43
- ;
- eod equ dspstr + 81
- ;
- stacktop equ eod + 512
- ;
- codeseg ends
- ;
- end entry
-