|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Assembly language problem, Renaming a file
hello guys,
I have an assignment to do...that is to create a file, input some string, rename the file and display the contents. well creating a file, inputing a string into the file and display the contents is working file. But I am not able to rename the file. I have developed procedures for each of these and posting the code below. Please see if you can help me with this. TITLE File Handling ; FILE: file.asm ; This program is to "read a filename from the keyboard. Create the file. Put some strings into the file. and rename it. Display the contents of the file. ;by Kunal Choudhary, 18/03/06 .MODEL SMALL .STACK 100H .DATA CR equ 13 LF equ 10 filedata db 50 dup(?) filename db 13 dup(?) fileret db 50 dup(?) newfilename db 13 dup(?) cnt db CR, LF, "Do you want to continue?(y/n) :- $" errinput db CR, LF, "Wrong Input! Try Again.$" menutitle db "Program to represent File Handling Operations$" menu1 db CR, LF, LF, LF,"1.Press 'c' to Create File$" menu2 db CR, LF, "2.Press 'r' to Rename File$" menu3 db CR, LF, "3.Press 'i' to Input File$" menu4 db CR, LF, "4.Press 'd' to Display File :-$, CR, LF" crglf db CR, LF, "$" menuctfile db CR, LF, "Enter File Name :- $" inptfile db CR, LF, "Enter text for File :- $" renfile db CR, LF, "Enter File Name to be Changed to :- $" filedisplay db CR, LF, "Displaying Content of File :- $" .CODE main PROC .STARTUP call menu .EXIT main ENDP menu PROC mov dx, offset menutitle mov ah, 09h int 21h s: mov dx, offset menu1 mov ah, 09h int 21h mov dx, offset menu2 mov ah, 09h int 21h mov dx, offset menu3 mov ah, 09h int 21h mov dx, offset menu4 mov ah, 09h int 21h mov ah, 01h int 21h cmp al, 'c' jne s1 call createfile jmp xt s1: cmp al, 'r' jne s2 call renamefile jmp xt s2: cmp al, 'i' jne s3 call inputfile jmp xt s3: cmp al, 'd' jne s4 call displayfile jmp xt s4: mov dx, offset errinput mov ah, 09h int 21h jmp s xt: mov dx, offset cnt mov ah, 09h int 21h mov ah, 01h int 21h cmp al, 'y' jne ext jmp s ext: ret menu ENDP createfile PROC mov dx, offset menuctfile mov ah, 09h int 21h mov si, 0 mov bx, offset filename c1: mov ah, 01h int 21h cmp al, 0Dh je c2 mov [bx+si], al inc si jmp c1 c2: mov BYTE PTR [bx+si], 0H mov dx, offset filename mov cx,32 mov ah, 3Ch int 21h ret createfile ENDP renamefile PROC mov dx, offset renfile mov ah, 09h int 21h mov si, 0 ;getting new file name. mov bx, offset newfilename r1: mov ah, 01h int 21h cmp al, 0Dh je r2 mov [bx+si], al inc si jmp r1 r2: mov BYTE PTR [bx+si], 0H mov dx, offset filename mov di, offset newfilename mov ah, 56h ;dos call to rename the file. int 21h ret renamefile ENDP inputfile PROC mov dx, offset inptfile mov ah, 09h int 21h mov si, 0 mov bx, offset filedata i3: mov ah, 01h int 21h cmp al, 0Dh je i4 mov [bx+si], al inc si jmp i3 i4: mov BYTE PTR [bx+si], 0H mov dx, offset filename mov al, 32 mov ah, 3Dh int 21h mov bx, ax mov cx,50 mov dx,offset filedata mov ah, 40h int 21h mov ah, 3Eh int 21h ret inputfile ENDP displayfile PROC mov dx, offset filedisplay mov ah, 09h int 21h mov dx, offset newfilename mov ah, 09h int 21h mov dx, offset crglf mov ah, 09h int 21h mov dx, offset newfilename mov al, 32 mov ah, 3Dh int 21h mov bx, ax mov cx, 50 mov dx, offset fileret mov ah, 3FH int 21h mov bx, offset fileret mov si, ax inc si mov BYTE PTR [bx+si], 24H mov dx, offset fileret mov ah, 09h int 21h ret displayfile ENDP END main |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Other Programming Languages > Assembly language problem, Renaming a file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|