I have to write a code which take string as input and write it into a file in assembly language. In my following code i have initialize a string in DUP and then write it into assembly language. But now i want to take intput from user and then write it into a file. How can i do it.
;
;Newline macro
newline macro
mov dx , 10
mov ah , 02h
int 21h
mov dx , 13
mov ah , 02h
int 21h
endm
; Macro to output string
stringoutput macro str1
lea dx , str1
mov ah , 09h
int 21h
endm
.model small
.stack 100h
.data
FNAME db "write.txt" , 0
string1 db 1 dup("Happy Codding!!")
string2 db "Write in File successful.$"
string6 db "*********Instruction**********$"
string3 db "For this program first you have to create a $"
string5 db "file named as write.txt in BIN folder then coninue..$"
.code
main proc
mov ax , @data
mov ds , ax
newline
stringoutput string6
newline
stringoutput string3
newline
stringoutput string5
newline
mov dx , offset FNAME
mov al , 02h
mov ah , 3Dh
int 21h
mov cx , lengthof string1
mov bx , ax
mov dx , offset string1
mov ah , 40h
int 21h
newline
stringoutput string2
newline
mov ah , 03eh
int 21h
mov ah , 04ch
int 21h
main endp
end main