Reputation: 21
I am trying to delete a file that has ".lnk" extension using assembly 8086 architecture. When I write "jmp DELETE" after "mov si, dx" and skip the inner, back1, back2, back3 part, my code deletes all the file, but when it checks if it has .lnk extension character by character, it doesn't delete any of them, not even the file with .lnk extension . Why is it happening?
.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
Upvotes: 2
Views: 390
Reputation: 39166
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'
Upvotes: 2