loading...

Assembly language program to create a file and delete an existing file

The following code helps us to create a file and delete an existing file using assembly language program.

print macro mrg
lea dx,msg
mov ah,09h
int 21h
endm
DATA SEGMENT
file1 db ‘exam.txt’,0; name of file to be created
file2 db 'exam1.txt’,0; name of file to be deleted
SC db 'creation successful $’
EC db 10,13,'error in the creation $’
SD db 10,13,'deletion success $’
ED db 10,13,'error in the deletion $’
Data ends
CODE SEGMENT
assume cs:code,ds:data 
Start:       mov ax,data
             mov ds,ax
             lea dx,file1
             mov cx,0000h
             clc
             mov ah,3ch
             int 21h
             jc err1
             print SC
             jmp next1
err1:        print EC
next1:       mov cx,0000h
             clc 
             lea dx,file2
             mov ah,4ch
             int 21h
             jc err2
             print SD
             jmp exit
err2:        print ED
exit:        mov ah,4ch
             int 21h
             code ends
             end start



The output of the above code is –

 
Output:
-g=0000 0049
Creation successful
Error in deletion
Ax=4C02 Bx=0000 Cx=0000 Dx=0054

Also read: Top 10 Best phones for gaming

0 2

Leave a Reply

Your email address will not be published.