我正在尝试创建一个文件夹,然后在里面创建一个.txt文件。它会创建文件夹和.txt文件,但它位于文件夹之外。程序也没有正确终止,因为输入输入后Dos框崩溃了。
这是我的代码:
.model small
.stack 100h
.data
buff db 30 ; allow 30 characters on string
total db 0
char db 30 dup (0) ; array, 30 duplicates of 0 (0,0...)
x db "Input a string: $"
y db 10, 13, "SUCCESS!$"
z db 10, 13, "FAILED!$"
a db "File.txt", 0
b dw ?
d db "Hello world!$"
.code
main proc near
mov ax, @data
mov ds, ax
call prompt
call input
call cfolder
call ctext
int 20h
main endp
prompt proc near
mov dx, offset x ; print x
mov ah, 9 ; accept string
int 21h
ret
prompt endp
input proc near
mov dx, offset buff
mov ah, 0ah ; buffered input
int 21h
ret
input endp
cfolder proc near
mov bh, 0 ; keyboard input
mov bl, total
add bx, offset char
mov byte ptr [bx], 0
mov dx, offset char ; char = filepath
mov ah, 39h ; make directory
int 21h
jnc succ
jc fail
ret
cfolder endp
ctext proc near
mov ah,3ch
mov cx,0
mov dx, offset a
int 21h
jc fail
mov b, ax
mov ah,40h
mov bx, b
mov dx, offset d
mov cx, 12 ; no. of characters
int 21h
jc fail
ret
ctext endp
succ proc near
mov dx, offset y ; displays SUCCESS!
mov ah,9
int 21h
ret
succ endp
fail proc near
mov dx, offset z ; displays FAILED!
mov ah,9
int 21h
ret
fail endp
end main
你能帮我找到错误并用正确的错误代替吗?