Difference between revisions of "83Plus:Software:usb8x/Asm Interface/MSD/DOS fileWrite"
From WikiTI
m |
m (Oops...function doesn't change attributes) |
||
Line 19: | Line 19: | ||
== Notes == | == Notes == | ||
− | + | Avoid overuse of this function, such as calling it hundreds of times to write one byte at a time. It is much better to write all hundred bytes at once. | |
Example code to write "This is a test" to "readme.txt" in the root directory: | Example code to write "This is a test" to "readme.txt" in the root directory: | ||
<code> | <code> |
Latest revision as of 00:46, 12 September 2006
Contents
[hide]Synopsis
Name: DOS_fileWrite
Minimum usb8x version: 0.10
Writes bytes to a file and grows it if necessary.
Inputs
- HL points to file handle of an opened file
- DE points to a buffer of bytes to write
- BC is the number of bytes to write
Outputs
- BC is the number of bytes actually written
- C set if problems
Destroys
- AF, BC, DE, HL
Notes
Avoid overuse of this function, such as calling it hundreds of times to write one byte at a time. It is much better to write all hundred bytes at once.
Example code to write "This is a test" to "readme.txt" in the root directory:
ld hl,sFilename
ld de,file_handle
U_CALL DOS_openFile
;HL points to file handle
ld de,sWrite
ld bc,14
U_CALL DOS_fileWrite
...
sFilename: DB "/readme.txt",0
sWrite: DB "This is a test"
If you are writing an application, you must copy the strings you use to RAM first, or else usb8x will not be able to see them.
See Also
- [[../DOS_fileRead|DOS_fileRead]] - Read bytes from a file at current seek pointer
- [[../DOS_fileSeek|DOS_fileSeek]] - Set seek pointer in file handle