Difference between revisions of "AMSDOS Header"

From CPCWiki - THE Amstrad CPC encyclopedia!
Jump to: navigation, search
 
(22 intermediate revisions by 4 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 consist of 128 bytes and contain 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:
  
Byte 00: User number (value from 0 to 15 or #E5 for deleted entries)
+
{| class="wikitable"
Byte 01 to 08: filename (fill unused char with spaces)
+
|-
Byte 09 to 11: Extension (fill unused char with spaces)
+
! Field !! Bytes !! Name !! Notes
Byte 16: first block (tape only)
+
|-
Byte 17: first block (tape only)
+
| rowspan="10" | System || 0 || User number || 0-15, or #E5 for deleted entries
Byte 18: file type (0:basic 1:protected 2:binary)
+
|-
Byte 21 and 22: loading address LSB first
+
| 1..8 || Filename || Unused characters are filled with space
Byte 23: first block (tape only?)
+
|-
Byte 24 and 25: file length LSB first
+
| 9..11 || Extension || Unused characters are filled with space
Byte 26 and 27: execution address for machine code program LSB first
+
|-
Byte 64 and 66: 24 bits file length LSB first
+
| 12..15 || Zero || Contains all zeroes
Byte 67 and 68: checksum for bytes 00-66 stored LSB first
+
|-
Byte 69 to 127: undefined content, free to use
+
| 16 || Block number || Tape only, set to 0
 +
|-
 +
| 17 || Last block || Tape only, set to 0
 +
|-
 +
| 18 || File type || As per cassette: Bit0 = Protection (set if protected)
  
To calculate the checksum just add all bytes from 00 up to and including byte 66 together.
+
Bits1..3 = File contents (0:BASIC, 1:Binary, 2:Screen image, 3:ASCII, 4..7 are unallocated)
 +
 
 +
Bits4..7 = Version (ASCII files should be version 1, all other files should be version 0)
 +
|-
 +
| 19..20 || Data length || As per cassette: the number of data bytes in the data record
 +
|-
 +
| 21..22 || Data location || As per cassette: where the data was written from originally
 +
|-
 +
| 23 || First block || Set to #FF, only used for output files
 +
|-
 +
| rowspan="3" | User || 24..25 || Logical length || As per cassette: actual file length is here
 +
|-
 +
| 26..27 || Entry address || As per cassette: the execution address for machine code programs
 +
|-
 +
| 28..63 || Unused || As per cassette
 +
|-
 +
| rowspan="3" | AMSDOS || 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 ||
 +
|}
 +
 
 +
 
 +
 
 +
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.
 +
 
 +
When a file without a header is opened for input, a fake header is constructed in store as follows:
 +
 
 +
{| class="wikitable"
 +
|-
 +
! Bytes !! Name !! Notes
 +
|-
 +
| 0 || User number || User number, #00..#FF
 +
|-
 +
| 1..8 || Filename || Unused characters are filled with space
 +
|-
 +
| 9..11 || Extension || Unused characters are filled with space
 +
|-
 +
| 12..15 || Zero || Contains all zeroes
 +
|-
 +
| 18 || File type || #16, unprotected ASCII version 1
 +
|-
 +
| 19..20 || Data location || Address of 2K buffer
 +
|-
 +
| 23 || First block || Set to #FF
 +
|}
 +
 
 +
All other fields are set to zero.
  
 
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]]
+
=== Expansion of the AMSDOS Header ===
 +
Some OS and DOS expanded the classic AMSDOS header:
 +
 
 +
1. [[FutureOS Header]]:
 +
* Contains and icon or information text
 +
* File length is 24 Bit
 +
* Defined Loading and Autostart (expansion) RAM configuration
 +
* Additional file types
 +
 
 +
[[Category:Disc Operating System]]
 +
[[Category:Programming]]

Latest revision as of 06:34, 24 October 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:

Field Bytes Name Notes
System 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, set to 0
17 Last block Tape only, set to 0
18 File type As per cassette: Bit0 = Protection (set if protected)

Bits1..3 = File contents (0:BASIC, 1:Binary, 2:Screen image, 3:ASCII, 4..7 are unallocated)

Bits4..7 = Version (ASCII files should be version 1, all other files should be version 0)

19..20 Data length As per cassette: the number of data bytes in the data record
21..22 Data location As per cassette: where the data was written from originally
23 First block Set to #FF, only used for output files
User 24..25 Logical length As per cassette: actual file length is here
26..27 Entry address As per cassette: the execution address for machine code programs
28..63 Unused As per cassette
AMSDOS 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


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.

When a file without a header is opened for input, a fake header is constructed in store as follows:

Bytes Name Notes
0 User number User number, #00..#FF
1..8 Filename Unused characters are filled with space
9..11 Extension Unused characters are filled with space
12..15 Zero Contains all zeroes
18 File type #16, unprotected ASCII version 1
19..20 Data location Address of 2K buffer
23 First block Set to #FF

All other fields are set to zero.

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

Expansion of the AMSDOS Header

Some OS and DOS expanded the classic AMSDOS header:

1. FutureOS Header:

  • Contains and icon or information text
  • File length is 24 Bit
  • Defined Loading and Autostart (expansion) RAM configuration
  • Additional file types