Assembly 从文本文件打印字符串的代码

Assembly 从文本文件打印字符串的代码,assembly,x86-16,dosbox,Assembly,X86 16,Dosbox,今年我在学习汇编程序,我不知道如何从文本文件中打印字符串,怎么做 我正在学习记事本++程序,并在dos框8086中运行该程序 谢谢你的帮助 proc OpenFile ; Open file for reading and writing mov ah, 3Dh mov al, 2 mov dx, offset filename int 21h jc openerror mov [filehandle], ax ret openerror:

今年我在学习汇编程序,我不知道如何从文本文件中打印字符串,怎么做

我正在学习记事本++程序,并在dos框8086中运行该程序

谢谢你的帮助

proc OpenFile
; Open file for reading and writing
    mov ah, 3Dh
    mov al, 2
    mov dx, offset filename
    int 21h
    jc openerror
    mov [filehandle], ax
    ret
openerror:
    mov dx, offset ErrorMsg
    mov ah, 9h
    int 21h
    ret
endp OpenFile
proc WriteToFile
; Write message to file
mov ah,40h
mov bx, [filehandle]
mov cx,12
mov dx,offset user_name
int 21h
ret
endp WriteToFile

proc CloseFile
       doPush ax,bx
; Close file
mov ah,3Eh
mov bx, [filehandle]
int 21h
doPop bx,ax
ret
endp CloseFile

以及如何从文本文件中读取和打印???

添加一个过程到读取,类似于写入的过程

proc ReadFromToFile
; Read message from file
mov ah, 3Fh
mov bx, [filehandle]
mov cx, 12
mov dx, offset user_name
int 21h
ret
现在,如果用户名是“Supermannix$”(注意末尾的$字符!),您可以使用

mov dx, offset user_name
mov ah, 09h
int 21h


收到了一个很好的答案,但我不认为你从中吸取了教训。这意味着您当前的OpenFile过程仍然存在相同的错误报告问题,您在该答案中找到了解决方案-顺便说一句,您现在可以接受这个问题了!(只需单击左侧的复选标记)

添加一个过程,以读取,类似于您为写入而获得的过程

proc ReadFromToFile
; Read message from file
mov ah, 3Fh
mov bx, [filehandle]
mov cx, 12
mov dx, offset user_name
int 21h
ret
现在,如果用户名是“Supermannix$”(注意末尾的$字符!),您可以使用

mov dx, offset user_name
mov ah, 09h
int 21h


收到了一个很好的答案,但我不认为你从中吸取了教训。这意味着您当前的OpenFile过程仍然存在相同的错误报告问题,您在该答案中找到了解决方案-顺便说一句,您现在可以接受这个问题了!(只需点击左边的复选标记)

但每次我用中断21输入一个新输入时,它都会超过上次在文本文件中的值。。怎么办?但每次我用中断21输入一个新的输入,它都会超过上次在文本文件中的值。。怎么办??