guys need help says when executed.The syntax of command is incorrect.. i dont where i went wrong..here is my code..

.model small
.stack 100h
.data
file   db   "TEST.TXT",0   ; File name
new   db   "Rename.txt",0   ; New name
dir  db "D:",0 ;Current directory
.code
start:
mov ax,seg dir
mov ds,ax 
mov dx, offset dir
mov ah,3Bh
int 21h
rename:
   mov   ah,56h      ; open file read/write
   lea   dx,file      ; points to file name
   lea   di,new      ; renames to
   
 

   int   21h	
   
end start

You're trying to buid a DOS application. Not a 32-bit or Extended DOS application.

Keep SEG out of it. Technically your code segment is your data segment and your stack segment!

It's a segment issue! This is just one way to get it to work!

.model small
	.stack 100h
;	.data
	.code
		

	; Change directory

start:
	mov ax,cs  ;seg dir
	mov ds,ax
	mov dx, offset dir
	mov ah,3Bh
	int 21h
	jc	abort

rename:   mov   ah,56h      ; open file read/write
   lea   dx,file      ; points to file name
   lea   di,new      ; renames to
   
   
   int   21h

abort:
	mov	ah,4ch
	int	21h

	dir  db "D:\",0 ;Current directory
	file   db   "TEST.TXT",0	; File name
	new   db   "Rename.txt",0   ; New name
	   
   end start

It is not a segment issue, he is generating an .exe file,
which uses multiple segments.

I got the code to work:

.model small
.stack 100h
.data
file db "TEST.TXT",0 ; File name
new db "Rename.txt",0 ; New name
.code
start:
; use function 0E to change drive
mov dl, 3 ; 0=A, 1=B, 2=C, 3=D
mov ah, 0eh
int 21h
mov ax, seg file
mov ds, ax ;LOAD ES & DS
mov es, ax
mov ah,56h ; open file read/write
lea dx,file ; points to file name
lea di,new ; renames to
int 21h
mov ax, 4c00h
int 21h
end start ; define entry point as start

What you did wrong was that Function 3Bh will not change
the current drive if the path contains a drive letter.
And you only loaded DS when function 56h takes:
DS : DX address of file name
ES : DI address of new name

You see a 16-bit old .EXE file header contains relocation
information to change segment references in the binary
image into actual segment addresses.
Because of this the .EXE program can place code,data,stack
on different and multiple segments making the total
limit of the programs size the amount of available system memory.
Unlike a TINY model program which has its code,data,and stack
on the same segment - hence a 64KB limit on .COM prog's size,
and taking PSP into account and NULL word 65,536-256-2.

ok ill try to do those stuff thnks..i need to work the code out for my proj..all i need is rename and open..delete create dir and create file are ok already thnks,, :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.