I am having trouble printing "I WIN!" to a file 100 times. I can get it to print but it prints with garble can someone please point out what I am doing wrong? I need the code to print without any garble with "I WIN!" one after the other.
.model small
.stack 100h
.data
handle dw ?
filename db "myfile.txt", 0
prompt1 db "ENTER FILE NAME HERE: $"
mess1 db ' I WIN! $'
.code
main:
mov ax, @data ; set up addressability of data
mov ds, ax
lea dx, prompt1 ; load and print the string PROMPT
mov ah, 9
int 21h
mov ah, 3ch ; dos service to create file
mov cx, 0
mov dx, offset filename
int 21h
jc failed ; end program if failed
mov handle, ax ; save file handle
mov cx, 100 ; number of bytes to write
PL:
mov ah, 40h ; write to
mov bx, handle ; file
mov dx, offset mess1 ; where to find data to write
dec cx
int 21h
jnz PL
mov ah, 3Eh ; close file
mov bx, handle ; which file
int 21h
failed:
mov ah, 4ch
int 21h
end main