★ CODING ★ CPC464/664/6128 Firmware ROM routines and explanations ★ |
CPC464/664/6128 Firmware ROM routines and explanations : 9 AMSDOS |
9 AMSDOS AMSDOS is a disc operating system used with all the CPC range of computers, of course, in the case of the 464 the DDI-1 has to be fitted. AMSDOS enables programs to access disc files in a similar manner to cassette files, indeed existing programs which currently use the cassette should be able to use disc files with little or no modification. The main source of incompatability will be filenames, AMSDOS filenames must conform to CP/M standards but cassette filenames are far less restricted. AMSDOS has been designed to complement CP/M, not to compete with it. They share the same file structure and can read and write each other's files. AMSDOS resides in the same ROM as the CP/M BIOS. AMSDOS provides the following facilities:
Whenever AMSDOS creates a new file it is always given a name with a type part of .$$$ regardless of the given name. When the file is closed any previous version of the file is renamed with a B A K type part and the new version is repamed from .$$$ to its proper name. Any existing .BAK version is deleted. This gives an automatic one level file back-up. For example, if the disc contains the files FRED.BAS and FRED.BAK and the user opens a file called FRED.BAS then AMSDOS will create a new file called FRED.$$$. When the file is closed the existing FRED.BAK is deleted, FRED.BAS is renamed to FRED.BAK and FRED.$$$ is then renamed to FRED.BAS. All AMSDOS facilities are implemented either by intercepting the cassette firmware calls or by external commands. The intercepted firmware calls are:
The remaining cassette firmware calls are not intercepted and remain unaffected. Full descriptions of both the tape and disc versions of these routines are given in section 15. The AMSDOS external commands are:
From BASIC all these commands must be preceded by a '|' Some of these commands require parameters. Full descriptions of these external commands are given in section 20. AMSDOS filenames are upwards compatible with CP/M filenames. But in addition the user number may also be specified and non-significant spaces are permitted before and after the name and any embedded punctuation. Examples:
If given, the user number must be in the range 0..15, the drive letter must be A or B. If either the user or the drive is given they must be followed by a colon. The following characters may be used in the name and type parts: a—z A—Z 0—9 ! " # $ & ‘ + — @ ‘ } { ~Any other characters will cause the command to fail with the message: BAD COMMANDThe characters "?" and "*" are wildcards, that is, when placed within a filename or type it will be interpreted as "any valid character". For example if the filename "G??E??.B*" was used in the |DIR command then the files "GAME1.BAS" , "GAME1.BAK" , "GAME29.BAS" and "GREET.BAS", and any other matching combinations, would be displayed in the directory. When parsing a filename, AMSDOS shifts lower case letters into upper case and removes bit 7. If the user or drive is omitted then the current default values are assumed. These defaults may be set by the user. If the type part is omitted then a default type is assumed. This depends on the context in which the name is being used, but usually a default type part of three spaces is assumed. Cassette files are subdivided into 2K blocks, each of which is preceded by header. CP/M files do not have headers. AMSDOS files may, or may not, have a header depending on the contents of the file. This will not cause problems for programs written in BASIC but is an important difference between cassette and disc files. Unprotected ASCII files do not have headers. All other AMSDOS files have a single header in the first 128 bytes of the file, the header record. 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. Thus it is possible, though unlikely, that a file without a header could be mistaken for one with a header. The format of the header record is as follows:
The use that the cassette manager makes of the header is described in section 8.4. AMSDOS uses the header as follows:
When a file without a header is opened for input a fake header is constructed in store as follows:
All other fields are set to zero. AMSDOS and the CP/M 2.2 BIOS support three different disc formats: SYSTEM format, DATA ONLY format, and IBM format. The CP/M Plus BIOS supports the SYSTEM and DATA formats but not IBM format. The BIOS automatically detects the format of a disc. Under CPIM this occurs for drive A at a warm boot and for drive B the first time it is accessed. Under AMSDOS this occurs each time a disc with no open files is accessed. To permit this automatic detection each format has unique sector numbers as detailed below. 3 inch discs are double sided, but only one side may be accessed at a time depending on which way round the user inserts the disc. There may be different formats on the two sides. Common To All Formats
System Format
The system format is the main format supported, CP/M can only be loaded (Cold Boot) from a system format disc. CP/M 2.2 also requires a system format disc to warm boot. The reserved tracks are used as follows.
CP/M Plus only uses Track 0 sector #41 as boot sector Track 0 sector #42... #49 and Track 1 are unused. Note: Another format called "VENDOR" format is a special version of system format which does not contain any software on the two reserved tracks. It is intended for use in software distribution. Data Only Format
This format is not recommended for use with CP/M 2.2 since it is not possible to "warm boot" from it. However, because there is a little more disc space available it is useful for AMSDOS or CP/M Plus. IBM Format
This format is logically the same as the single-sided format used by CP/M on the IBM PC. It is intended for specialist use and is not otherwise recommended as it is not possible to ‘warm boot' from it. In order that non-CP/M systems may be implemented at a later date the BIOS initialization is performed, in part, by a boot program which is read from the disc before attempting to load CP/M. In the non-CP/M case the boot program would not jump to the warm boot routine but go its own way, using the BIOS and firmware routines as desired. The boot program is in the boot sector which is the first sector (sector #41) on track 0. During a cold boot the BIOS is initialized into a minimum state before loading and executing the boot program. This state is as follows.
The boot sector is read and loaded into store at #0100; the stack pointer is initialized to a value immediately below the BIOS's data (#AD33 is normal) area and the boot program is entered at #0100. The boot program may use store from #0100 upwards until it reaches the stack. To run CP/M the boot program must, at least, jump to the warm boot entry in the ROM jumpblock. The boot program for CP/M 2.2 loads and obeys the configuration sector and then warm boots CP/M. The boot program for CP/M Plus searches for, loads and executes a file with the type part .EMS. The boot program has the following interface: Entry:
Exit:
The ROM copy of the BIOS jumpblock should not be used at any other time (indeed, only the boot program knows where it is). AMSDOS uses the CP/M 2.2 BIOS in order to access the disc. Thus BIOS In the following < drive > means A or B, < filename > means an AMSDOS Bad commandThere is a syntax error in a command or filename. < filename > already existsThe user is trying to rename a file to a name which is already in use. <filename> not foundThe user is trying to open for input, erase or rename a file that does not exist. Drive < drive >: directory fullThere are no more free directory entries (64 directory entries per disc). Drive < drive >: disc fullThere are no more free disc blocks. Drive < drive >: disc changed, closing < filename >The user has changed the disc while files were still open on it. < filename > is read onlyThe user is trying to erase or rename a file which is marked read-only. May 9.7 BIOS Facilities Available To AMSDOS AMSDOS uses the CP/M BIOS 2.2 to access the disc. In order that a program NOTE: The BIOS extended jumpblock itself is not available, indeed it does The BIOS routines available and their command names are as follows:
These routines are described in section 19. The word at #BE40 contains the address of the disc parameter header vector. Only the BIOS facilities mentioned here maybe used from a program When initialized AMSDOS reserves #500 bytes of memory from the memory When loading a machine code program from disc into store using the AMSDOS reserves store from the top of the memory pool so the simplest Alternatively the machine code program could be loaded in two stages: first In order to initialize AMSDOS using KL INIT BACK, AMSDOS's ROM Existing machine code programs, developed on cassette systems without any 9.9 Extended Disc Parameter Blocks In order to facilitate reading and writing ‘foreign' discs of differing formats,all There are two XPBs, one per drive. XPB structure:
The XPB for a drive may be found by accessing the Disc Parameter Header The values stored in the standard CP/M 2.2 DPB (Disc Parameter Block) are
The XPBs for the different formats are initialized as follows: System Format
Data Only Format
IBM Format
|