opening and reading a character from a file with emu8086 assembler
- From: spamtrap@xxxxxxxxxx
- Date: Sat, 24 Sep 2005 18:32:08 +0000 (UTC)
Hi! I am new to assembly. I am currrently writing a program that opens
a file, reads on character at a time and print each character on the
screen. It prints the '$' character in a seemingly infinite loop. Here
is my code:
org 100h ;.com memory layout
mov dx, offset file ;address of file to dx
mov al,0 ;openfile (read-only)
mov ah,3dh
int 21h ;call the interupt
jc terminate ;if error occurs, terminate program
mov bx,ax ;put handler to file in bx
mov cx,1 ;read one character at a time
print:
mov ah,3fh ;read from the opened file (its handler in bx)
int 21h
jc terminate ;end program if end of file is reached
mov ax,dx ;char is in dl, send to ax for printing (char is in
al)
mov ah,0eh ;print character
int 10h
jmp print ;repeat if not end of file
terminate:
ret
file db "c:\input.txt",0
handle dw ?
so where is the bug?
.
- Follow-Ups:
- Re: opening and reading a character from a file with emu8086 assembler
- From: Assembler Helper
- Re: opening and reading a character from a file with emu8086 assembler
- From: JGCASEY
- Re: opening and reading a character from a file with emu8086 assembler
- From: Dirk Wolfgang Glomp
- Re: opening and reading a character from a file with emu8086 assembler
- From: Frank Kotler
- Re: opening and reading a character from a file with emu8086 assembler
- Prev by Date: Re: [Clax86list] Re: resource files and assembler
- Next by Date: Re: Masm 8
- Previous by thread: Re: [Clax86list] Re: resource files and assembler
- Next by thread: Re: opening and reading a character from a file with emu8086 assembler
- Index(es):
Relevant Pages
|