Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old March 18th, 2006, 11:19 AM
kunal13123 kunal13123 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 20 kunal13123 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 43 m 17 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Assembly language problem, Renaming a file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway