Start New Discussion within our Software Development Community

Need Help to fix this code because I can not find the errors so they can read successfully.


Pila SEGMENT STACK ;Segmento de pila
DW 64 DUP (?)
Pila ENDS

Datos SEGMENT ;SEgmento de datos

Filename db 'C:\Tasm\BIN\Prue.txt',0
FHndl dw ?
msjFrase db 13,10,"Escriba la frase:$"
ERRORS db 13,10,"Error con el archivo$"
Buffer db 50h dup(?)


Datos ENDS


Codigo SEGMENT ;segmento de codigo
ASSUME CS:Codigo, DS: Datos, SS:Pila

mov ax, Datos ;trae un dato del segmento de datos
mov ds, ax

call leerArchivo
exit:
mov ah,4ch ;Prepare el programa para terminar
int 21h


leerArchivo proc near

mov ah, 3dh ;Open the file
mov al, 0 ;Open for reading
lea dx, Filename ;Presume DS points at filename
int 21h ; segment
jc BADOPEN
mov FHndl, ax ;Save file handle

LP:
mov ah,3fh ;Read data from the file
lea dx, Buffer ;Address of data buffer
mov cx, 1 ;Read one byte
mov bx, FHndl ;Get file handle value
int 21h
jc BADOPEN
cmp ax, cx ;EOF reached
jne EOF
jmp LP ;Read next byte

EOF: mov bx, FHndl
mov ah, 3eh ;Close file
int 21h
jc BADOPEN

BADOPEN:

mov ah,02h
mov bh,08
mov dh,11H
mov dl,cl
int 10h

LEA DX , ERRORS
mov ah , 09
int 21h
jmp exit


ret
leerArchivo endp

Codigo ENDS
END

Need Help to fix this code because I can not find the errors so they can read successfully.

Can you be more specific? What isn't this code doing right? Does it compile, does it run, does is produce any useful output?

Also, please use CODE tags. It will prevent the smilies from happening... so "ASSUME CS:Codigo, DS: Datos, SS:Pila" will look right:

ASSUME CS:Codigo, DS: Datos, SS:Pila
This article has been dead for over six months. Start a new discussion instead.