Difference between revisions of "83Plus:Software:usb8x/Asm Interface/MSD/DOS createFile"

From WikiTI
Jump to: navigation, search
(Brandon forgot he used the OP registers. . .)
Line 16: Line 16:
=== Destroys ===
=== Destroys ===
* AF, BC, DE, HL
* AF, BC, DE, HL
* OP registers
== Notes ==
== Notes ==

Revision as of 16:11, 19 October 2008


Name: DOS_createFile

Minimum usb8x version: 0.10

Creates a new file in specified directory of size 0.


  • BC points to the starting cluster of the directory to create file in (obtained with [[../FAT_getStartingCluster|FAT_getStartingCluster]])
  • HL points to an ASCIIZ string of the filename (ex. "test.txt")


  • File is created with size 0
  • C set if problems


  • AF, BC, DE, HL
  • OP registers


The file created date/time attributes are set according to the 84+/SE clock. Example code to create "readme.txt" in "test" directory:

ld hl,sDirectory
U_CALL FAT_getStartingCluster
push hl
pop bc ;BC contains starting cluster
ld hl,sFilename
U_CALL DOS_createFile
sFilename: DB "readme.txt",0
sDirectory: DB "/test",0

To read/write to this file, you must then open the file with [[../DOS_openFile|DOS_openFile]].

See Also

  • [[../FAT_getStartingCluster|FAT_getStartingCluster]] - Get starting cluster of specified directory
  • [[../DOS_openFile|DOS_openFile]] - Open file for reading and writing