SoloCodigo
Programación General => ASM (Ensamblador) => Mensaje iniciado por: Ares en Domingo 25 de Noviembre de 2007, 01:00
-
Hola, soy nuevo aqui, mi problemita es el siguiente tengo este código en NASM y lo necesito en MASM el código es el siguiente
org 100h
start:
mov ah, 0x1A ; Set DTA table adress
mov dx, DTA
int 21h
;call clean_name
mov ah, 0x4E
xor cx, cx ; no attributes
mov dx, squery
int 21h
jc theend ; no files matching query found
mov ah, 9
mov dx, fname
int 21h
find_next:
mov ah, 0x4F
mov dx, squery
int 21h ; find next matching file
jc theend ; no more files found
mov ah, 9
mov dx, fname
int 21h
jmp find_next
theend:
mov ah, 0x4C
int 21h
clean_name:
mov cx, 13
mov di, fname
xor ax, ax
repe stosb ; fill name with zeros incase memory has some ugly stuff or smth left from last search
ret
squery db "*.*", 0x0 ; search query, must end with zero
DTA resb 0x15 ; ignore useless DOS data
fattr db 0x0 ; file attribute
ftime dw 0x0 ; file creation/modification time
fdate dw 0x0 ; file creation/modification date
fsize dw 0x0 ; file size
fsmth dw 0x0
fname resb 14 ; file name terminated with zero
db 0xD, 0xA ; New line
db "$" ; 0xD - tells DOS to go to new line.
eh estado trabajando... según yo, para pasarlo a MASM y me quedo lo siguiente con el MASM611 que me lo compila ya sin errores pero tambien sin resultados:
.MODEL TINY
.STACK 100H
.186
.DATA
squery DB '*.*' ; search query, must end with zero
DTA dw 0 ; ignore useless DOS data
FATTR DB 0 ; file attribute
ftime DW 0 ; file creation/modification time
fdate DW 0 ; file creation/modification date
fsize DW 0 ; file size
fsmth DW 0
fname DW 0 ; file name terminated with zero
DB 13, 10 ; New line
DB '$' ; 0xD - tells DOS to go to new line.
.CODE
.STARTUP
start:
mov ah, 26 ; Set DTA table adress
mov dx, DTA
int 21h
;call clean_name
mov ah, 78
xor cx, cx ; no attributes
mov dx, 'NOSE'
int 21h
jc theend ; no files matching query found
mov ah, 9
mov dx, fname
int 21h
find_next:
mov ah, 79
mov dx, 'NOSE'
int 21h ; find next matching file
jc theend ; no more files found
mov ah, 9
mov dx, fname
int 21h
jmp find_next
theend:
mov ah, 76
int 21h
clean_name:
mov cx, 13
mov di, fname
xor ax, ax
rep stosb ; fill name with zeros incase memory has some ugly stuff or smth left from last search
ret
.EXIT
END
cualquier ayuda o tutorial o referencia de donde puedo encontrar solución es bienvenida, mi intención es hacer una emulación en MASM del comando dir, de antemano gracias.
-
Los errores mas claros son al declarar las variables:
DTA dw 0 ; ignore useless DOS data
Eso son solo 2 bytes y el original son 21 bytes.
Declararlo asi:
DTA db 21 dup(0) ; ignore useless DOS data
Lo mismo va para fname.
Y squery tiene que terminar en 0, asi:
squery DB "*.*", 0 ; search query, must end with zero
Te va a dar error donde estes usando estas variables ya que hasta ahora estabas pasando su valor (0) y no su direccion, usa offset. Donde usaste 'NOSE', usa el offset de squery.
Con eso mas o menos deberia funcionar, aunque no esta de mas hacer un call clean_name justo antes de jmp find_next (si usas un MS-DOS real - no bajo Windows - vas a darte cuenta).
-
SOY YO OTRA VEZ, MUCHISIMAS GRÁCIAS POR LA AYUDA, ESTUBE PROBANDO TUS CONSEJOS Y EL CÓDIGO ME QUEDO DE LA SIGUIENTE MANERA:
.MODEL TINY
.STACK 100H
.186
.DATA
squery DB '*.*',0 ; search query, must end with zero
DTA db 21 dup(0) ; ignore useless DOS data
FATTR DB 0 ; file attribute
ftime DW 0 ; file creation/modification time
fdate DW 0 ; file creation/modification date
fsize DW 0 ; file size
fsmth DW 0
fname DB 21 DUP(0) ; file name terminated with zero
DB 13, 10 ; New line
DB '$' ; 0xD - tells DOS to go to new line.
.CODE
.STARTUP
start:
mov ah, 26 ; Set DTA table adress
mov dx, OFFSET DTA
int 21h
;call clean_name
mov ah, 78
xor cx, cx ; no attributes
mov dx, OFFSET SQUERY
int 21h
jc theend ; no files matching query found
mov ah, 9
mov dx, OFFSET fname
int 21h
find_next:
mov ah, 79
mov dx, OFFSET SQUERY
int 21h ; find next matching file
jc theend ; no more files found
mov ah, 9
mov dx, OFFSET fname
int 21h
jmp find_next
theend:
mov ah, 76
int 21h
clean_name:
mov cx, 13
mov di, OFFSET fname
xor ax, ax
rep stosb ; fill name with zeros incase memory has some ugly stuff or smth left from last search
ret
.EXIT
END
POR SI ALGUIEN LE SIRVE, ESTA FUNCIONANDO, SOLAMENTE MUESTRA ARCHIVOS, NO DIRECTORIOS, PERO YO CREO QUE ESO YA NO SERIA TANTO PROBLEMA, SALUDOS Y MUCHAS GRACIAS NUEVAMENTE.