我正在创建一个程序,用户输入.txt文件名及其内容,然后程序可以读取并打印该.txt文件的内容。
This one is the part where the user will type the content and .txt file
This one is the part where the program prints the contents of the .txt file
变量:
buff4 db 30
total4 db 0
char2 db 30 dup (0)
buff9 db 250
total9 db 0
text db 250 dup (0)
g db "Input text:$"
;view memo NEW
a db "Filename:$"
uMaxLength db 255
uActualLength db ?
szFileName db 255 dup (?)
buffer db 100 dup (?), '$'
创建文本文件:
crm proc near
call cls
call content
call promptt
call input2
call file
jmp open
crm endp
content proc near
mov ah, 2
mov dl, 16
mov dh, 8
int 10h
mov dx, offset buff9 ; buffered input
mov ah, 0ah
int 21h
mov bh, 0 ; keyboard input
mov bl, total9
add bx, offset text
mov byte ptr [bx], 0
mov dx, offset text
cmp text, 'B'
je open
jne cmptexte
ret
content endp
promptt proc near
mov ah, 2
mov dl, 33
mov dh, 5
int 10h
ret
promptt endp
input2 proc near
mov dx, offset buff4
mov ah, 0ah
int 21h
mov bh, 0
mov bl, total4
add bx, offset char2
mov byte ptr [bx], 0
cmp char2, 'B'
je open
ret
input2 endp
file proc near
mov ah, 3ch
mov cx, 0
mov dx, offset char2
int 21h
mov h, ax ;preserve
mov ah, 40h ;write
mov bx, [h]
mov cx, 250 ;string length
mov dx, offset text
int 21h
mov ah, 3eh ;close file
mov bx, [h]
int 21h
ret
file endp
打印文本文件:
view proc near
call cls
mov ax, seg uMaxLength
mov ds, ax
mov ah, 0ah
lea dx, uMaxLength ;read file name
int 21h
mov ah, 2
mov dl, 16
mov dh, 8
int 10h
mov al, uActualLength
xor ah, ah
mov si, ax
mov szFileName[si], 0 ;make sz see 0A function
cmp szFileName, 'B'
je open
jne cmpex
view endp
cmpex proc near
cmp szFileName, 'E'
je exit
jne view2
cmpex endp
view2 proc near
mov ah, 3dh
xor al, al
lea dx, szFileName
int 21h ;open the file
jc view ;if error
mov bx, ax
repeat:
mov ah, 3fh
lea dx, buffer
mov cx, 100
int 21h
jc view; if error
mov si, ax
mov buffer[si], '$'
mov ah, 09h
int 21h ;print on screen
cmp si, 100
je repeat
call tdbe
ret
view2 endp
cmpb proc near
cmp openin, 'B'
je menu
jne cmpee
ret
cmpb endp
cmpee proc near
cmp openin, 'E'
je exit
jne open
ret
cmpee endp
我可以做些什么,以便文本不会出黑色文本框?提前谢谢!