Int21h - renaming a file
Int21h - renaming a file
Hi guys
Im trying to write a little assembly code which will rename a file and here is the code :
mov ah, 56h
mov dx, [fileName]
mov di [newName]
int 21h
salc
cmp ah, 0h
je .succes
fileName db "text.txt", 0
newName db "test.txt", 0
im assembling with NASM and after that i type this in terminal :
cat main.o text.txt > floppy.img
qemu floppy.img
But even if the name is wrong it allways go to .succes ..
What am i doing wrong? :s
Im trying to write a little assembly code which will rename a file and here is the code :
mov ah, 56h
mov dx, [fileName]
mov di [newName]
int 21h
salc
cmp ah, 0h
je .succes
fileName db "text.txt", 0
newName db "test.txt", 0
im assembling with NASM and after that i type this in terminal :
cat main.o text.txt > floppy.img
qemu floppy.img
But even if the name is wrong it allways go to .succes ..
What am i doing wrong? :s
Re: Int21h - renaming a file
omg... you cat it to make a floppy?
also, int 21h is in dos...
also, int 21h is in dos...
Re: Int21h - renaming a file
yeah cant i do that ? it boots up fine?
Aint it just a real mode interrupt?
Aint it just a real mode interrupt?
- Khaoticmind
- Member
- Posts: 29
- Joined: Tue Nov 18, 2008 1:06 pm
- Location: Brazil
Re: Int21h - renaming a file
For what i know int21 is a DOS interrupt, as shiner said, and because of that it works only on DOS.
That said you can't use it in OS Deving.
Also, you can't create a floppy using cat.
Probably this function to rename a file was developed to work on a FAT formated disk. Doing a cat you are just "forcing the file to be there", so to say, you are not actually storing it in the file system.
Hope this made things clearer to you.
If not ask out and i try to elaborate more on that.
That said you can't use it in OS Deving.
Also, you can't create a floppy using cat.
Probably this function to rename a file was developed to work on a FAT formated disk. Doing a cat you are just "forcing the file to be there", so to say, you are not actually storing it in the file system.
Hope this made things clearer to you.
If not ask out and i try to elaborate more on that.
Re: Int21h - renaming a file
It did make it alot more clear, but how do a make a "floppy image" then `? i need to make it virtual because i dont have a working floppy disc..
Okay but if i format it in FAT can i then use the int21h call or do i need to find another solution?
Okay but if i format it in FAT can i then use the int21h call or do i need to find another solution?
- Khaoticmind
- Member
- Posts: 29
- Joined: Tue Nov 18, 2008 1:06 pm
- Location: Brazil
Re: Int21h - renaming a file
That really depends on the OS you are using.Baxos wrote:It did make it alot more clear, but how do a make a "floppy image" then `? i need to make it virtual because i dont have a working floppy disc..
If its Linux you can use these commands to create a FAT formated floppy
Code: Select all
dd if=/dev/zero of=/floppy.img bs=512 count=2880
mkdosfs floppy.img
Code: Select all
mcopy -i floppy.img youfile.txt ::/
IF you are doing OS development (thats why you are here, right? ), than no, you can't use it.Okay but if i format it in FAT can i then use the int21h call or do i need to find another solution?
To accomplish a renaming file function you would need to first write an OS, with memory management, floppy driver, and a file system. THEN you could work on the rename function.
Cheers
Last edited by Khaoticmind on Wed Dec 17, 2008 10:38 am, edited 1 time in total.
Re: Int21h - renaming a file
In addition to the multitude of problems outlined above, you also probably want the pointer to fileName and newName, not the first word.
Cheers,
Adam
Cheers,
Adam
Re: Int21h - renaming a file
Okay thankes alot that helped alot i will start working on some of thoose things
-
- Member
- Posts: 566
- Joined: Tue Jun 20, 2006 9:17 am
Re: Int21h - renaming a file
May be you should do something like this
and set everthing properly before calling int 21 h .
Regards
Shrek
Code: Select all
mov bx , 0
push bx
pop es
mov bx, offset handler
mov es:[21 *4 ], bx
mov bx, seg handler
mov es:[21 *4 + 2], bx
Regards
Shrek