為什麼這個彙編代碼不刪除擴展名為“.lnk”的文件? (Why doesn't this assembly code delete the file with ".lnk" extension?)


問題描述

為什麼這個彙編代碼不刪除擴展名為“.lnk”的文件? (Why doesn't this assembly code delete the file with ".lnk" extension?)

我正在嘗試使用程序集 8086 架構刪除擴展名為“.lnk”的文件。當我在“mov si, dx”之後寫“jmp DELETE”並跳過內部、back1、back2、back3 部分時,我的代碼會刪除所有文件,但是當它逐個字符檢查它是否具有 .lnk 擴展名時,它不會t 刪除其中任何一個,甚至不刪除擴展名為 .lnk 的文件。為什麼會這樣?

.MODEL SMALL
.STACK 100H
.DATA
FILE DB "*", 0
DTA DB 128H DUP(?)   
FILENAME DB 50 DUP(?)
.CODE

MAIN PROC  

    MOV AX,@DATA
    MOV DS,AX

    ;SET DTA
    MOV DX,OFFSET DTA
    MOV AH,1AH
    INT 21H

    ;FIRST SEARCH
    MOV DX,OFFSET FILE 
    MOV CX,0
    MOV AH,4EH
    INT 21H
    JC QUIT

OUTER_LOOP:


    ;DELETE
    LEA DX,DTA+30 
    mov si, dx 

    inner:
    cmp [si], 0
    je back1
    inc si
    jmp inner

    back1:
    dec si
    cmp [si],'K'
    je back2
    jmp NEXT

    back2:
    dec si
    cmp [si],'N'
    je back3
    jmp NEXT

    back3:

    dec si
    cmp [si], 'L'


    delete:
    LEA DX,DTA+30 
    MOV AH,41H
    INT 21H


    ;INITIATE NEXT SEARCH
    NEXT:
    MOV DX,OFFSET FILE 
    MOV CX,0
    MOV AH,4FH
    INT 21H
    JC QUIT

    JMP OUTER_LOOP



QUIT:
    MOV AX,4C00H
    INT 21H

MAIN ENDP
    END MAIN

參考解法

方法 1:

These points might interest you:

  • Change your filemask to

    *.*
    
  • Why do you set up such a large DTA?.

    DTA 44 dup(?)
    
  • Always write cmp byte ptr [si], ...

  • Don't stop comparing after the 3 characters. Add a fourth compare to see if the point is present. Then you'll know that LNK is indeed a file extension.

  • Your 4Fh DOS call doesn't need the CX and DX parameters.

  • You don't interpret the result from

    cmp [si], 'L'
    

(by harmione Sep Roland)

參考文件

  1. Why doesn't this assembly code delete the file with ".lnk" extension? (CC BY‑SA 2.5/3.0/4.0)

#emu8086 #assembly #x86-16 #file-management






相關問題

使用 include 'emu8086.inc' 反轉字符串的大小寫和順序 (Reverse case and order of a String using include 'emu8086.inc')

emu8086 : ARR 不包含任何值 (emu8086 : ARR do not contain any value)

為什麼這個彙編代碼不刪除擴展名為“.lnk”的文件? (Why doesn't this assembly code delete the file with ".lnk" extension?)

將 C 代碼轉換為 8086 程序集 (Converting C code into 8086 assembly)

循環無法打印字母 (Loop does not work to print alphabets)

如何使用 call 和 ret 更改堆棧內容? (how to change stack content with call and ret?)

彙編語言中的putch函數通過堆棧 (putch function in assembly language through stack)

如何在不使用 HLT 的情況下對程序進行 HLT (How to HLT the program without using HLT)

使用 8086 彙編計算 10 的階乘 (Computing the factorial of 10 using 8086 assembly)

你好,我有一個問題,我需要從用戶那裡得到輸入,輸入是一個數字和一個數字後的數字,數字可以是雙字 (hello , i got a question that i need to get input from user, the input is a number and digit after digit ,the number can be a doubleWord)

在彙編語言中得到錯誤的結果 (Getting wrong result in Assembly language)

我的氣泡代碼是彙編語言嗎? (is my code for bubble right at assembly language?)







留言討論