我在下面写了这个程序,但它没有用。我输入的文件名为dur.txt
。它返回AX = 4C03。为什么它不起作用,我该如何纠正呢?
.model tiny
.data
max1 db 32
act1 db ?
inp1 db 30 dup(0)
hande dw ?
.code
.startup
;enter the name of the file
lea dx,max1
mov ah,0ah
int 21h
;delete the file
mov ah,41h
lea dx, inp1
int 21h
.exit
end
答案 0 :(得分:5)
start:
;enter the name of the file
lea dx,max1
mov ah,0ah
int 21h
mov si,offset act1 ; inc si is coming before cmp, so start ahead
lookup:
inc si
cmp byte ptr [si],0Dh
jnz lookup
mov byte ptr[si],0
;delete the file
mov ah,41h
lea dx, inp1
int 21h
提示:如果你" inc si"比较之后,你将销毁它的标志设置。所以我在比较之前移动了inc si,并且SI必须在缓冲区之前加载一个字节。 ps:查找非常简单(而且很危险,它在内存中找不到任何0x0D之前没有停止!),我非常确定x86循环指令在哪里: - )
(再次)迈克尔(再次)正确地说,输入缓冲区的第二个字节将告诉输入的字符串是多长时间(以及0x0d的位置,因为它是输入的最后一个字母)。所以没有必要搜索它,它在[inp1 + [act1]]start:
lea dx,max1 ;enter the name of the file
mov ah,0ah
int 21h
pick:
mov si,offset inp1 ; get offset of entered string
xor bh,bh
mov bl,[act1] ; and it's len (the CR should be there)
mov byte ptr [bx+si],0 ; replace it with a 0
mov ah,41h ;delete the file
lea dx, inp1
int 21h