Rename a file using assembly programming.


 
Write a program to rename a file assembly program.

 Write assembly program to rename a file.

 Rename a file using assembly programming.

 

Program:-

;rename file

printstring macro msg

mov ah,09h

mov dx,offset msg

int 21h

endm

data segment

imsg1 db 13,10,"Enter name of the file to rename:$"

imsg2 db 13,10,"Enter new name of the file to rename:$"

smsg db 13,10,"Success :-)$"

fmsg db 13,10,"Faliure :-($"

dname db 20 dup(0) ;stores the name of the file to be renamed

nname db 20 dup(0) ;new name of the file

data ends

code segment

assume cs:code,ds:data

 

start:

mov ax,data

mov ds,ax

mov es,ax

 

;input the name of the file to be renamed

printstring imsg1

mov si,offset dname

ri:

 mov ah,1

int 21h

cmp al,13

je rj ;jumps to take the input for the new file name

mov [si],al

inc si

jmp ri

;input the new name of the file

rj:

printstring imsg1

mov si,offset nname

rk:

 mov ah,1

int 21h

cmp al,13

je crd

mov [si],al

inc si

jmp rk

crd:

 mov ah,56h

 mov dx,offset dname

 mov di,offset nname

 int 21h

jnc succ

printstring fmsg

jmp exit

succ:printstring smsg

exit:

mov ah,4ch

int 21h

code ends

end start

No comments:

Post a Comment