Assembly Disc Access Primer, a TatungBytes course: DISKMON reading the hidden sector IDs of the course's own practice disc, on a rainbow sunburst
← Back to Modules
module
29

Appendix I: The BDOS File Calls

With XtalDOS loaded. Every call: function number in C, then CALL 5. 0005h holds JP EC00H.

The FCB (36 bytes)

ByteHolds
0Drive: 0 current, 1 drive 0, 2 drive 1
1-8Name, capitals, padded with spaces
9-11Extension, padded with spaces
12Extent (filled by open)
1480h after an open (the BDOS's own)
15Record count of the extent (filled by open)
16-31Block numbers, 16-bit, low byte first (filled by open)
33-35Record number for read/write random, low byte first (35 = 0)

The Calls

CCallGive itGet back in A
2Print a characterE = character
9Print a stringDE = text ending $ (not printed)
15OpenDE = FCBFFh not found; else 0-3 (the entry's place among four)
16CloseDE = FCB0-3
19DeleteDE = FCB0; FFh not found. Sets byte 0 of every entry to E5h, nothing else
20Read sequentialDE = FCB0 read; 1 end of file. Moves to the next extent itself
21Write sequentialDE = FCB0
22MakeDE = FCB0-3. The entry is listed at once, empty until closed
23RenameDE = FCB, new name from byte 16 (byte 16 = 0)0; FFh not found. Renames every extent
26Set DMA addressDE = addressReads and writes use 128 bytes there. 0080h when a program starts
33Read randomDE = FCB, record in 33-350 read; 1 no such record; 4 no such extent
34Write randomDE = FCB, record in 33-350. Past the end lengthens the file

Rules

  • Test open with CP 0FFH, never OR A.
  • Close a file you have written, or the directory says it is empty.
  • Disc errors are the DOS's: No Sector 1: / Try Again(Y/N)? (N abandons your program), No Drive 1: / No.(0-3)?. Your program gets no error code.
  • In MAME a write to a .dsk fails (Bad Data 1:); use an .mfi.

Memory

Address
0000hJP FA03H: JP 0 restarts the DOS and restores the CCP
0005hJP EC00H
0080hDefault DMA address
0100hYour program, loaded and called here
E100h-EBFFhThe CCP. Your entry stack (EB18h) and return address (EAD9h) are in it: leave it alone if you end with RET
EC00hThe BDOS

Get the Newsletter

New guides, disk images and community finds, roughly once a quarter. No spam, we promise, this isn't Tatung's marketing department.
Your subscription could not be saved. Please try again.
Your subscription has been successful.

Newsletter

Subscribe to our newsletter and stay updated.

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.