Difference between revisions of "AMSDOS Header"
Line 3: | Line 3: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
− | ! Bytes !! Name !! Notes | + | ! Field !! Bytes !! Name !! Notes |
|- | |- | ||
− | | 0 || User number || 0-15, or #E5 for deleted entries | + | | rowspan="10" | System || 0 || User number || 0-15, or #E5 for deleted entries |
|- | |- | ||
| 1..8 || Filename || Unused characters are filled with space | | 1..8 || Filename || Unused characters are filled with space | ||
Line 29: | Line 29: | ||
| 23 || First block || Set to #FF, only used for output files | | 23 || First block || Set to #FF, only used for output files | ||
|- | |- | ||
− | | 24..25 || Logical length || Actual file length is here. As per cassette | + | | rowspan="3" | User || 24..25 || Logical length || Actual file length is here. As per cassette |
|- | |- | ||
| 26..27 || Entry address || The execution address for machine code programs. As per cassette | | 26..27 || Entry address || The execution address for machine code programs. As per cassette | ||
Line 35: | Line 35: | ||
| 28..63 || Unused || As per cassette | | 28..63 || Unused || As per cassette | ||
|- | |- | ||
− | | 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! | + | | 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 | | 67..68 || Checksum || Unsigned sum of all bytes until this field | ||
Line 41: | Line 41: | ||
| 69..127 || Unused || | | 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. | 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. |
Revision as of 05:16, 15 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 | 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 | The number of data bytes in the data record. As per cassette | |
21..22 | Data location | Where the data was written from originally. As per cassette | |
23 | First block | Set to #FF, only used for output files | |
User | 24..25 | Logical length | Actual file length is here. As per cassette |
26..27 | Entry address | The execution address for machine code programs. As per cassette | |
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.
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.