WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
 

I need help with code to find files, the following code finds only for folders, but I need to find files

trex15
Quote Post


New Member
*

Group: Members
Posts: 12
Member No.: 25781
Joined: 23-August 09


The following code only for folders
I need to find files sad.gif
thanks for any help


.MODEL SMALL
.STACK 1024H
.DATA


LONG_NOM_FICH=40

Msg1 DB 'Introduzca el nombre del FICHERO: $'
Msg2 DB 'Total de Ficheros (Hex.):$'
Msg3 DB 'Error en el acceso',0dh,0ah
Avanza DB 0Dh,0Ah, '$'
Tabla DB '0123456789ABCDEF' ;Tabla para imprimir el número
;Buffer de entrada del teclado
BufEnt DB LONG_NOM_FICH+1
DB ?
ASCIIZ DB LONG_NOM_FICH DUP (?); Con DUP (?)
DTASeg DW ? ;Segmento del DTA Disk Transfer Area.



NumFich DW 0 ;Número de Ficheros que coinciden.

.CODE

;Macro para copiar cadena de Entrada.
CopiarZ MACRO destino ;comienza la Macro CopiarZ
cld ;Limpiar flags de acarreo
mov cl,[BufEnt+1];Longitud de la cadena
xor ch,ch
mov si,OFFSET BufEnt+2
mov di,OFFSET destino
rep movsb; Lee el contenido del operando origen
;y lo copia en el operando destino, los elementos
;Destino y Origen serán los elementos ES:DI Y DS:SI
;respectivamente.
xor al,al ;Pone el 0 al final de la cadena
stosb ;Copia el contenido del acumulador cx en el elemento apuntado por ES:DI
ENDM ;Termina la macro CopiarZ



;Macro para enviar un mensaje y leer una cadena
Input MACRO Mensaje
mov ah,9
mov dx,OFFSET mensaje
int 21h
mov ah,0Ah
mov dx,OFFSET BufEnt
int 21h
mov ah,9
mov dx,OFFSET Avanza
int 21h
ENDM
Entrada PROC
cld
mov ax,@DATA
mov ds,ax
mov [DTASeg],es ;Guarda el segmento de la DTA
mov es,ax ;funcionará Copiarz
mov es,ax
Input Msg1 ;Llamamos a la macro: Input MACRO Mensaje
;y le pasamos el valor Msg1 guardado en Data.

CopiarZ ASCIIZ ;Convertimos el Fichero a ASCII

mov ah,4eh
mov cx,17h
mov dx,OFFSET ASCIIZ
int 21h
jc Final

Bucle:
;Incrementamos el número de Ficheros encontrados

inc [NumFich]
;Cambia el número de fichero encontrado a ASCIIZ
mov es,[DTASeg]
mov di,80h+30
mov cx,13 ;Bytes a examinar
xor al,al ;Valor a buscar
repne scasb
dec di ; Para apuntar al 0
mov al,'$' ;Fin de la cadena para el servicio 9 del DOS
;Sustituyendo al 0.
stosb
;Mostramos el nombre del fichero coincidente

push ds
mov ah,9
mov ds,[DTASeg];Directamente de la DTA
mov dx,80h+30
int 21h
pop ds
mov ah,9
mov dx,OFFSET Avanza
int 21h
mov ah,4Fh
int 21h
jc Final
;Encontrado , continuar
jmp Bucle

Final:
;Comprobar si ha ocurrido un error o no
cmp ax,12h ;Código de error de no hay más ficheros
jne error ;si es 12h , no es error
;Mostrar mensaje final
mov ah,9
mov dx,OFFSET Msg2
int 21h

;Convertir el número a exadecimal y mostrarlo
IRP ROT,<12,8,4,0>; Lo repite 4 veces
mov bx,[NumFich]
mov cl,ROT
shr bx,cl
and bx,0Fh
mov dl,Tabla[bx]
mov ah,2
int 21h
ENDM
;Avanza a la siguiente línea

mov ah,9
mov dx,OFFSET Avanza
int 21h

;Salir con ERRORLEVEL=0

mov ax,4c00h
int 21h

Error:
;Mostrar mensaje de error
mov ah,9
mov dx,OFFSET Msg3
int 21h

;Retornar ERRORLEVEL=1
mov ax,4c01h
int 21h
Entrada ENDP; aqui se acaba Entrada Proc

END Entrada ; aqui se acaba el programa
PMEmail Poster
Top
shoorick
Quote Post


Extremely Active Member
******

Group: Admins
Posts: 2301
Member No.: 160
Joined: 22-June 04


CODE
...
CopiarZ ASCIIZ;Convertimos el Fichero a ASCII

mov ah,4eh
mov cx,17h
...

-- try to play with attributes, try 0, 7, 3, 27, 37 instead of 17 etc. - these bits interpretation is tricky
PMEmail PosterUsers Website
Top
trex15
Quote Post


New Member
*

Group: Members
Posts: 12
Member No.: 25781
Joined: 23-August 09


QUOTE (shoorick @ Aug 30 2009, 09:33 PM)
-- try to play with attributes, try 0, 7, 3, 27, 37 instead of 17 etc. - these bits interpretation is tricky

thanks for reply, it seems that the issue is very difficult sad.gif
PMEmail Poster
Top
shoorick
Quote Post


Extremely Active Member
******

Group: Admins
Posts: 2301
Member No.: 160
Joined: 22-June 04


QUOTE
The cx register contains the search attributes for the file. Normally, cx should contain zero. If non-zero, Find First File (and Find Next File) will include file names which have the specified attributes as well as all normal file names.
PMEmail PosterUsers Website
Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google