home *** CD-ROM | disk | FTP | other *** search
-
- name tryunix
- page 55,132
- title 'tryunix'
-
- ;
- ; Example of File Searching Using
- ; the "Unix-like" Functions 4EH and 4FH
- ;
-
- cseg segment para public 'CODE'
-
- assume cs:cseg,ds:cseg,es:cseg,ss:cseg
-
- org 100h
-
- start proc far
-
- mov dx,offset mybuff ;set DTA to working
- mov ah,1ah ;buffer for DOS
- int 21h
- mov dx,offset fname ;Search for First
- mov cx,0 ;normal file attributes
- mov ah,4eh
- int 21h
- jc exit ;no match found, quit
-
- display:
- mov dx,offset crlf ;send carriage return/
- mov cx,2 ;line feed sequence
- mov bx,1
- mov ah,40h
- int 21h
- mov cx,0 ;cx will be length
- mov si,offset mybuff+30 ; of filename
-
- display1:
- lodsb ;count characters in
- or al,al ;filename until null
- je display2 ;byte is encountered
- inc cx
- jmp display1
-
- display2:
- mov dx,offset mybuff+30 ;offset of filename
- mov bx,1 ;handle 1 = std output
- mov ah,40h ;function 40h = Write
- int 21h
-
- nextfile:
- mov ah,4fh ;Search for Next
- int 21h
- jnc display ;match found, display
-
- exit: mov ah,0 ;return to DOS
- int 21h
-
- crlf db 0dh,0ah
-
- fname db '*.ASM',0 ;ASCIIZ file spec to
- ;be matched
-
- mybuff db 64 dup (0) ;working buffer for DOS
-
- start endp
-
- cseg ends
-
- end start