Difference between revisions of "AMSDOS Header"

From CPCWiki - THE Amstrad CPC encyclopedia!
Jump to: navigation, search
(wrong byte offsets for file length and checksum (thanks to Targhan))
m
 
(8 intermediate revisions by 5 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
+
! Offset !! Size !! Name !! Notes
Byte 09 bis 11: Extension
+
|-
Byte 18: type-byte
+
| 0 || BYTE || User number || 0-15, or #E5 for deleted entries
Byte 21 and 22: loading address
+
|-
Byte 24 and 25: file length
+
| 1 || 8 BYTES || Filename || Unused characters are filled with space
Byte 26 and 27: execution address for machine code programs
+
|-
Byte 64 and 65: (file length)
+
| 9 || 3 BYTES || Extension || Unused characters are filled with space
Byte 67 and 68: checksum for byte 00 to byte 66
+
|-
</pre>
+
| C || DWORD || Zero || Contains all zeroes
 +
|-
 +
| 10 || BYTE || Block number || Tape only
 +
|-
 +
| 11 || BYTE || Last block || Tape only
 +
|-
 +
| 12 || BYTE || 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")
 +
|-
 +
| 13 || WORD || Data location || Address of the 2KB buffer
 +
|-
 +
| 15 || WORD ||Load address ||
 +
|-
 +
| 17 || BYTE || First block || Set to #FF, only used for output files
 +
|-
 +
| 18 || WORD ||style="white-space: nowrap;"|  Logical length || Actual file length is here
 +
|-
 +
| 1A || WORD || Entry address ||
 +
|-
 +
| 1C || 36 BYTES || Unused ||
 +
|-
 +
| 40 || 3 BYTES || Real length || 24-bit number. Just a copy, not used!
 +
|-
 +
| 43 || WORD || Checksum || Unsigned sum of all bytes until this field
 +
|-
 +
| 45 || 59 BYTES || Unused || Free to use
 +
|}
  
To calculate the checksum, just add byte 00 to byte 66 to each other.
+
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 15:49, 7 November 2023

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:

Offset Size Name Notes
0 BYTE User number 0-15, or #E5 for deleted entries
1 8 BYTES Filename Unused characters are filled with space
9 3 BYTES Extension Unused characters are filled with space
C DWORD Zero Contains all zeroes
10 BYTE Block number Tape only
11 BYTE Last block Tape only
12 BYTE 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")
13 WORD Data location Address of the 2KB buffer
15 WORD Load address
17 BYTE First block Set to #FF, only used for output files
18 WORD Logical length Actual file length is here
1A WORD Entry address
1C 36 BYTES Unused
40 3 BYTES Real length 24-bit number. Just a copy, not used!
43 WORD Checksum Unsigned sum of all bytes until this field
45 59 BYTES Unused Free to use

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.