I am writing a DOS program to make a file and write into it. I have to write the data in two different lines. Here is my code:
.model tiny
.486
.data
fname db 'file5.txt',0
handle dw ?
msg db 'Prashant Pandey 2014A7PS100G'
.code
.startup
mov ah,3eh
mov bx,handle
int 21h
mov ah,3ch ;the 4 lines from now open an new non-existing.3ch is used to open a new file
lea dx,fname
mov cl,2h
int 21h
mov handle,ax
mov ah,40h ;these 4 lines write to the already opened file
mov bx,handle
mov cx,28h
lea dx,msg
int 21h
; new line
mov dx,13
mov ah,2
int 21h
mov dx,10
mov ah,2
int 21h
mov ah,40h ;these 4 lines write to the already opened file
mov bx,handle
mov cx,28h
lea dx,msg
int 21h
mov ah,3eh
mov bx,handle
int 21h
.exit
end
I am using MASM and DOSBOX. The problem is although the program prints the data in two different lines, but before the 2nd line, it also prints some weird characters and then prints the string msg. What is wrong with this program, and how can I fix it?