Category : Batch File Utilities - mostly for DOS
Archive   : ABFS.ZIP
Filename : WD.ASM

 
Output of file : WD.ASM contained in archive : ABFS.ZIP
page 55,132
title WD.ASM -- WHICH DIRECTORY

cgroup group code_seg,data_seg
assume cs:cgroup,ds:cgroup

dta struc

rsvd db 21 dup (?) ;dos use
attribute db 0
time dw 0
date dw 0
size dd 0
name_found db 13 dup (?)

dta ends
page

code_seg segment para public 'code'

org 100h ;for .com file use

WD proc far
push si
push ax
mov si,080h
lodsb
cmp al,0
pop ax
pop si
je ret0 ;quit, no parms
mov si,082h ;command line first char
mov di,offset cgroup:file_name ;place to store it
gsn: lodsb ;get a character into al
cmp al,0dh ;is it cr?
je drn ;yup, quit
stosb ;nope, go for more
jmp short gsn ;until you hit cr.
drn: xor al,al ;store asciiz zero at end
stosb ;as search spec.
mov di,offset cgroup:path_name
xor al,al ;in case of recursion
mov cx,64
cld
repnz scasb ;scan for zero at end
mov bx,di
dec bx
mov dx,0
call sdir
ret0: int 20h
WD endp

page

sdir proc near
push si
push dx
call bn
call gfm
jc nomatch
call wmn
fnf: call gnm

jc nomatch
call wmn
jmp short fnf
nomatch: pop dx
push dx
mov si,dx
call bsn
call gfm
jc nmm
mov si,dx
test [si].attribute,010h ;is this a directory?
jnz isd
fnd: call gnm
jc nmm
test [si].attribute,010h ;is this a directory?
jz fnd
isd: cmp [si].name_found,'.' ;dot or dot-dot?
je fnd
call ssd
push ax
mov ah,01ah ;reset dta
int 21h
pop ax
jmp short fnd
nmm: pop dx
pop si
ret
sdir endp

page

ssd proc near
push di
push si
push ax
push bx
cld
mov si,dx
add si,offset name_found
mov di,bx
cloop: lodsb
stosb
or al,al
jnz cloop
mov bx,di
std
stosb
mov al,'\'
stosb
call sdir
pop bx
mov byte ptr[bx],0
pop ax
pop si
pop di
ret
ssd endp

wmn proc near
push ax
push dx
mov dx,offset cgroup:path_name
mov al,[bx]
mov byte ptr [bx],0
call ws
mov [bx],al
pop dx
push dx
add dx,offset name_found
call ws
call scrlf
pop dx
pop ax
ret
wmn endp

bn proc near
push si
mov si,offset cgroup:file_name
call build
pop si
ret
bn endp

bsn proc near
push si
mov si,offset cgroup:star_name
call build
pop si
ret
bsn endp

page

build proc near
push ax
push di
mov di,bx
cld
cname: lodsb
stosb
or al,al
jnz cname
pop di
pop ax
ret
build endp

gfm proc near
push cx
cmp dx,0
ja allocate
mov dx,offset cgroup:disk_transfer_areas-type dta
allocate: add dx,type dta
mov cx,10h
mov ah,01ah
int 21h
push dx
mov dx,offset cgroup:path_name
mov ah,04eh
int 21h
pop dx
pop cx
ret
gfm endp

gnm proc near
push cx
push dx
mov dx,offset cgroup:path_name
mov cx,010h
mov ah,4fh
int 21h
pop dx
pop cx
ret
gnm endp

scrlf proc near
push ax
push dx
mov ah,02
mov dl,0dh
int 21h
mov dl,0ah
int 21h
pop dx
pop ax
ret
scrlf endp

ws proc near
push ax
push dx
push si
cld
mov si,dx
mov ah,2
lodsb
wsl: mov dl,al
int 21h
lodsb
or al,al
jnz wsl
pop si
pop dx
pop ax
ret
ws endp

code_seg ends
page

data_seg segment para public 'data'

star_name db '*.*',0 ;asciiz search argument
path_name db '\',0 ;asciiz root path name
db 80 dup(0) ;total of 81 bytes of zero
file_name db 13 dup(0)
disk_transfer_areas label byte
data_seg ends

end WD


  3 Responses to “Category : Batch File Utilities - mostly for DOS
Archive   : ABFS.ZIP
Filename : WD.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/