83Plus:Software:usb8x/Asm Interface/MSD/DOS fileWrite

From WikiTI
Revision as of 01:34, 17 August 2006 by Brandonw (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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

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