🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.lang.asm
Article #331

Re: Newbie: File operations

#331
From: Alexei A. Frounze
Date: Wed, 15 Mar 2000 00:00
90 lines
3340 bytes
1. File is *opened* by the *create* function. So you must close it
before termination.
2. Filename in MSDOS is represented by ASCIIZ string but not with "$" at
the end.
3. If you want to put a binary number, you must specify that this is a
binary number:
15 (decimal)
0Fh (hex)
1111b (binary)
These 3 numbers are the same but in written down different bases
(10,16,2).

Look:
---------------------8<-------------------------
codeseg segment use16
        assume cs:codeseg, ds:codeseg, es:codeseg, ss:codeseg
        org 100h

start:
        mov     cx, 20h         ; normal (not *backed up*) file attr
        mov     ah, 3ch         ; *create and open* file function
        lea     dx, fname
        int     21h

        mov     bx, ax          ; bx = file handle
        mov     ah, 3eh         ; *close* file function
        int     21h

        mov     ax, 4c00h       ; *quit* function
        int     21h

fname   db      "test.txt",0

codeseg ends

end     start
---------------------8<-------------------------

Good Luck 
Alexei A. Frounze


Nutty Professor wrote:
> 
> Here's the code for creating a file. It always gave some sort of an error.
> Thanks for the help.
> 
> HELLO  segment
>   assume  cs:HELLO, ds:HELLO, es:HELLO
>   org     100h
> 
> start:  mov ah,09h
> 
> mov ah, 3C    ;To open the file with a handle
> mov cx, 00100000   ;The attribute
> 
>   mov bx,cs  ;pointing to the ASCIIZ filename
>   mov ds,bx
>   mov dx,offset mytext
> 
> mytext  db 'test.txt','$'
> 
>   mov ax,4c00h
>   int 21h
> 
> HELLO  ends
> 
> end start
> 
> Al Leitch [Team2000] wrote in message <8aka9j$9hi$1@bob.news.rcn.net>...
> >Could you please put up your source codes for us?
> >
> >---------------------------------------------------------------
> >Team2000 PC/Palm Pilot Programming Team:
> >http://ppilot.homepage.com
> >
> >Nutty Professor wrote:
> >
> >> Hi!
> >>
> >> I am a newbie in assembly and would like to know about File operations. I
> >> had a look at HelpPC but the programs I made didn't seem to work. Could
> >> someone make a few programs on file operations with comments to
> demonstrate
> >> how to work with files?
> >>
> >> Thanks in advance.
> >>
> >>
> >
Technical Details
Message-ID: <8amnom$1dh$1@bob.news.rcn.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <scr874c0a5n45@corp.supernews.com> <8aka9j$9hi$1@bob.news.rcn.net> <8alolr$8eq$1@bob.news.rcn.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: feaef,9d73404c09218118
X-Google-Attributes: gidfeaef,public
X-Google-Thread: f7d8d,9d73404c09218118
X-Google-Attributes: gidf7d8d,public
X-Google-Thread: 114917,9d73404c09218118
X-Google-Attributes: gid114917,public
From: "Alexei A. Frounze" <alex.fru@mtu-net.ru>
Subject: Re: Newbie: File operations
Date: 2000/03/15
Message-ID: <8amnom$1dh$1@bob.news.rcn.net>
X-Deja-AN: 597595347
Content-Transfer-Encoding: 7bit
Approved: <johnfine@erols.com>
References: <scr874c0a5n45@corp.supernews.com> <8aka9j$9hi$1@bob.news.rcn.net> <8alolr$8eq$1@bob.news.rcn.net>
X-Accept-Language: en,ru
Content-Type: text/plain; charset=us-ascii
X-Track2: 2
X-Mozilla-Status: 0801
X-Complaints-To: abuse@rcn.com
X-Trace: /cIFrhCtGjRaD4W/IgYnj+uMkp/ylIKUBMJtUgp4cTk=
X-Apparently-To: clax86@yahoo.com via web1705.mail.yahoo.com
Organization: MTU-Intel ISP
X-Track: 1-1: 40
Mime-Version: 1.0
NNTP-Posting-Date: 15 Mar 2000 01:07:34 GMT
Newsgroups: alt.lang.asm,borland.public.tasm,comp.lang.asm.x86