05-07-2011، 10:31 PM
Eng:
Remove File With Assembly Code
Persian:
با کد زیر میتونید یاد بگیرید که چگونه یک فایل رو پاک کنید.
Remove File With Assembly Code
Persian:
با کد زیر میتونید یاد بگیرید که چگونه یک فایل رو پاک کنید.
کد پیاچپی:
;----------------------------------------------
;Deleting file
; ---------------------------------------------
ermac macro ;//print error message if can't delete file
lea dx,errormsg
mov ah,09h
int 21h
endm
;//////////////////////////////////
okmac macro ;//print the file deleted succsesfuly if it can delete file
lea dx,okmsg
mov ah,09h
int 21h
endm
;//////////////////////////////////
datasg segment 'code'
fil db 'c:\programmer.blogsky.com.txt',00h
okmsg db 'the file deleted succsesfuly',"$"
errormsg db 'error in deleting file',"$"
datasg ends
;--------------------------------
codesg segment 'code'
main proc far
assume ds:datasg,cs:codesg
mov ax,datasg
mov ds,ax
lea dx,fil ;/file name that maust be deleted
mov ah,41h ;/function for deleting file
int 21h ;/interupt for deleting directory
jnc l1 ;/go to l1 if deleting file is succsessfull
ermac ;/call error macro and print error message if can't delete file
jmp l2 ;/goto end program
l1: okmac ;/call okmac if it can delete file and print successfull
l2: mov ax,4c00h;/end of program
int 21h
main endp
codesg ends
end main