LTHT
.Model small
.Stack 100h
.Data
filename db 30 dup(0)
rootpath db 30 dup(?)
dta db 128 dup(0)
msg1 db 'nhap vao ten tep can xoa $' ,0ah,0dh
msg2 db 0Ah,0Dh,'file not found ! $'
msg3 db 0Ah,0Dh,'successful ! $'
.Code
MAIN proc
mov ax,@data
mov ds,ax
mov es,ax
;hien thi thong bao 1
lea dx,msg1
mov ah,09h
int 21h
call SET_DTA
xor bx,bx
xor cx,cx
call GET_NAME
call GET_ROOTPATH
call XOA
mov ax,4c00h
int 21h
MAIN endp
SET_DTA proc ; dat DTA
mov ax,seg dta
mov ds,ax
mov dx,offset dta
mov ah,1ah
int 21h
ret
SET_DTA endp
GET_NAME proc
push ax
push dx
CLD ; xoa DF cho thao tac chuoi
lea di,filename
mov ah,1
read_name:
int 21h ; ki tu trong AL
cmp al,0dh
jz done
STOSB ; luu ki tu tu AL vao chuoi chi boi DI ( Filename )
inc cx
jmp read_name
done:
pop dx
pop ax
ret
GET_NAME endp
GET_ROOTPATH proc
STD ;dat co DF=1 de dinh huong cho SI giam
mov si,di ; SI chi den cuoi chuoi filename
lea di,rootpath
path_1:
LODSB ;chuyen tung byte cua chuoi filename
; ( vi tri SI cho) vao AL
cmp al,"\" ; AL= "\" ?
jz new_str
dec cx
jmp path_1
new_str:
add cx,1
mov bx,cx
lap:
push ax
LODSB
loop lap
mov cx,bx
CLD ; xoa DF=0 de dinh huong cho DI tang
top:
pop ax
STOSB
loop top
ret
GET_ROOTPATH endp
XOA proc
mov ax,seg filename
mov ds,ax
mov dx,offset filename
mov ah,4eh
int 21h
jc msg_false
find_next:
lea si,dta+1eh
push di
mov cx,12
REP MOVSB
mov ax,seg rootpath
mov ds,ax
mov dx,offset rootpath
mov ah,41h
int 21h
pop di
mov ah,4fh
int 21h
jc finish
jmp find_next
msg_false:
lea dx,msg2
mov ah,9
int 21h
jmp exit
finish:
lea dx,msg3
mov ah,9
int 21h
exit:
ret
XOA endp
END MAIN
Bạn đang đọc truyện trên: Truyen247.Pro