Difference between revisions of "AMSDOS Header"

From CPCWiki - THE Amstrad CPC encyclopedia!
Jump to: navigation, search
(Link to details in Firmware Guide chapter 9, page 4.)
 
(11 intermediate revisions by 7 users not shown)
Line 1: Line 1:
In [[AMSDOS]] it is possible to store files in two ways: headerless and with a header. Headerless files are often files which were created with [[OPENOUT]] and ''SAVE"filename",a''. Programs normally have a file header, which is consists of 128 bytes and contains the following data:
+
In [[AMSDOS]] it is possible to store files in two ways: headerless and with a header. Headerless files are often files which were created with [[OPENOUT]] and ''SAVE"filename",a''. Programs normally have a file header, which consist of 128 bytes and contain the following data:
  
<pre>
+
{| class="wikitable"
Byte 00: User number
+
|-
Byte 01 to 08: filename
+
! Bytes !! Name !! Notes
Byte 09 bis 11: Extension
+
|-
Byte 18: type-byte
+
| 0 || User number || 0-15, or #E5 for deleted entries
Byte 21 and 22: loading address
+
|-
Byte 24 and 25: file length
+
| 1..8 || Filename || Unused characters are filled with space
Byte 26 and 27: execution address for machine code programs
+
|-
Byte 64 and 65: checksum for byte 00 to byte 66
+
| 9..11 || Extension || Unused characters are filled with space
Byte 67 and 68: (file length)
+
|-
</pre>
+
| 12..15 || Zero || Contains all zeroes
 +
|-
 +
| 16 || Block number || Tape only
 +
|-
 +
| 17 || Last block || Tape only
 +
|-
 +
| 18 || File type || 0:BASIC 1:Protected 2:Binary (ASCII files don't have headers but a fake header is built in memory with the file type #16, "Unprotected ASCII v1")
 +
|-
 +
| 19..20 || Data location || Address of the 2KB buffer
 +
|-
 +
| 21..22 ||Load address ||
 +
|-
 +
| 23 || First block || Set to #FF, only used for output files
 +
|-
 +
| 24..25 ||style="white-space: nowrap;"|  Logical length || Actual file length is here
 +
|-
 +
| 26..27 || Entry address ||
 +
|-
 +
| 28..63 || Unused ||
 +
|-
 +
| 64..66 || Real length || Length of the file in bytes, excluding the header record. 24 bit number, least significant byte first. Just a copy, not used!
 +
|-
 +
| 67..68 || Checksum || Unsigned sum of all bytes until this field
 +
|-
 +
| 69..127 || Unused || Free to use
 +
|}
  
To calculate the checksum, just add byte 00 to byte 66 to each other.
+
These headers are detected by checksumming the first 67 bytes of the record. If the checksum is as expected then a header is present, if not then there is no header.
 +
 
 +
To calculate the checksum, just add all bytes from 00 up to and including byte 66 together.
  
 
This is only a summary. All details are in [[Firmware Guide]] chapter 9, page 4.
 
This is only a summary. All details are in [[Firmware Guide]] chapter 9, page 4.
  
[[Category:Programming]] [[Category:Disc Operating System]]
+
[[Category:Disc Operating System]]
 +
[[Category:Programming]]

Latest revision as of 11:43, 11 July 2024

In AMSDOS it is possible to store files in two ways: headerless and with a header. Headerless files are often files which were created with OPENOUT and SAVE"filename",a. Programs normally have a file header, which consist of 128 bytes and contain the following data:

Bytes Name Notes
0 User number 0-15, or #E5 for deleted entries
1..8 Filename Unused characters are filled with space
9..11 Extension Unused characters are filled with space
12..15 Zero Contains all zeroes
16 Block number Tape only
17 Last block Tape only
18 File type 0:BASIC 1:Protected 2:Binary (ASCII files don't have headers but a fake header is built in memory with the file type #16, "Unprotected ASCII v1")
19..20 Data location Address of the 2KB buffer
21..22 Load address
23 First block Set to #FF, only used for output files
24..25 Logical length Actual file length is here
26..27 Entry address
28..63 Unused
64..66 Real length Length of the file in bytes, excluding the header record. 24 bit number, least significant byte first. Just a copy, not used!
67..68 Checksum Unsigned sum of all bytes until this field
69..127 Unused Free to use

These headers are detected by checksumming the first 67 bytes of the record. If the checksum is as expected then a header is present, if not then there is no header.

To calculate the checksum, just add all bytes from 00 up to and including byte 66 together.

This is only a summary. All details are in Firmware Guide chapter 9, page 4.