Re: create a file
- From: Frank Kotler <fbkotler@xxxxxxxxxxx>
- Date: Mon, 16 May 2005 22:56:39 -0400
Utilisateur1 wrote:
You know what? You've got a problem even before the one
we've already identified...
> mov ax,3d01h ; open file
This opens an *existing* file. If "FIL.TXT" doesn't already
exist, this will fail with error 2. Look into subfunction
3Ch - create file (set cx to the "attributes" you want). You
*don't* want to use this on an existing file if you want to
keep its contents and write more to it! In that case, you'll
want to use subfunction 3Dh, as you've got, followed by
subfunction 42h...
mov ax, 4202h ; seek to end of file
mov bx, handle ; or "dword ptr handle", *not* "offset
handle"!
xor cx, cx ; no offset from EOF
xor dx, dx
int 21h
jc erreur
.... *now* you can write new data to the file.
> mov dx, offset fildat
> int 21h
> jb erreur ; error in french
Since you seem to be able to print a number, you might want
to display the error code before quitting. It might help you
figure out what's going wrong.
> mov offset handle,ax
> mov ax,4200h
> mov bx, offset handle
Here's the problem...
> xor cx,cx ; begin byte 0
> mov dx,0001 ; 1st byte modified is the second
> int 21h
> jb erreur
.... and if you print out the error number, it'll be "invalid
handle" (once you get this far), I'll bet. I'm not sure what
you intend to do here. Skip over just one byte???
> mov ah,40h ; write file
> mov bx,offset handle
> mov cx,20h ; write 32 bytes
> mov dx,offset week
> int 21h
> jb erreur
Again, if you get to this point and fail, you might want to
see what the error number was...
....
> fildat db: "FIL.TXT",0 ; save date ant time
> handle db: ,0,0
There may be another "syntax issue" here... as I recall, in
"Intel syntax":
handle dw 0
is different from:
handle: dw 0
The second is a "label", and not a "variable"... "mov bx,
handle" may be treated as "offset handle" anyway. I don't
know what a86 makes of "handle dw: 0" (or "handle db: ,0,0")
- and I'm not gonna boot up dos and run a86 to find out! But
I suspect that removing all the ":"s from the data
declarations may help... although it may cause a86 to
complain about "mov offset xxx, ax", etc. (as it should!).
I hope the yakkin' about "syntax" doesn't distract you from
the "main point" - the difference between an address, and
the value that resides at that address. One you've figured
out which you want, figuring out what syntax you need to get
what you want - whether it's "offset" or "#" or "word ptr"
or "W" (a86) or nothing - should be the "easy part"...
relatively speaking...
Best,
Frank
.
- References:
- create a file
- From: Utilisateur1
- create a file
- Prev by Date: Re: Fast UTF-8 strlen function
- Next by Date: Flaw in Intels Hyper-Threading
- Previous by thread: Re: create a file
- Next by thread: Q about file processing re:cache
- Index(es):
Relevant Pages
|