正如Michael所說的那樣,您按下的[ENTER]也存儲在輸入緩衝區內。你必須用0來取代它之前,你可以調用INT 21/41
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 loopup指令somwhere :-)
as(again)Michael said (再次),輸入緩衝區的第二個字節會告訴輸入的字符串是多長時間(以及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
你'inp1'獲得該字符包括最終cariiage回報。假設您要返回的文件的名稱不包含任何回車符。 – Michael
使用好老的「debug.com」,跟蹤第一個int21h後面的程序,看看輸入了什麼......它不是真的int 21/41h期望的;-) – Tommylee2k
這是刪除,不會刪除(標題,代碼評論) –