1

我必须编写一个以字符串为输入的代码并将其写入汇编语言的文件中。在我的以下代码中,我在 DUP 中初始化了一个字符串,然后将其写入汇编语言。但现在我想从用户那里获取输入,然后将其写入文件。我该怎么做。

;           
;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
4

0 回答 0