Saturday, November 3, 2007

File Rename

Program :


printstring macro msg
mov ah,09h
lea dx,msg
int 21h
endm
_DATA segment
cr equ 0dh
lf equ 0ah

msg1 db cr,lf,'Enter the name of the file to be renamed :$'
msg2 db cr,lf,'Enterthe new name :$'
msg3 db cr,lf,'duplicate name or file not found$'
old db 80 dup(0)
new db 80 dup(0)
_DATA ends

_CODE segment
assume cs:_CODE,ds:_DATA

start: mov ax,_DATA
mov ds,ax
mov es,ax
printstring msg1
lea si,old

rdchar1: mov ah,01h
int 21h
cmp al,cr
je skip1
mov [si],al
inc si
jmp rdchar1

skip1: printstring msg2
lea si,new

rdchar2:mov ah,01h
int 21h
cmp al,cr
je skip2
mov [si],al
inc si
jmp rdchar2

skip2: mov ah,56h
lea dx,old
lea di,new
int 21h
jnc succ
printstring msg3

succ: mov ah,4ch
mov al,00h
int 21h
_CODE ends
end start

0 comments: