The FLEX operating system uses track 0 of each disk for its own housekeeping. Sectors 1 and 2 contain a boot program. Sector 3 holds the System Information Record (SIR), which tells FLEX the geometry of the disk, where the first empty sector is located and the number of empty sectors, among other things. The directory information is stored from sector 5 onward.
The boot process consists of three stages. First, the boot ROM loads sectors 1 and 2 of the disk into memory. These sectors contain a secondary boot loader. Second, the boot loader will load the operating system, contained in the FLEX.SYS file. Third, the boot loader jumps to FLEX entry point at address $CD00.
The boot loader in ROM can be rather simple. All it has to do is load two raw sectors (512 bytes) into memory and jump to the correct entry point. There is some freedom here; the exact load address is not critical as long as the code doesn’t use the area where FLEX will be loaded later. In effect, memory located below $C000 is safe to use.
The purpose of the secondary boot loader is to load the FLEX.SYS file. This file is formatted like any other FLEX binary; it consists of records which hold a load address and a record size followed by up to 252 payload bytes.
Unlike the ROM boot loader, the secondary loader must adhere to the FLEX disk layout as the FLEX.SYS can be fragmented on the disk. To simplify things a little, boot sectors 1 and 2 have a pointer to the starting track and sector where FLEX.SYS resides. The user can set this pointer using the LINK utility.
The track and sector of the FLEX.SYS file are written to track 0, sector 1 (the first sector on the disk), at offsets 5 and 6 respectively. This way, the secondary boot loader does not have to traverse the directory list, keeping the code small.
During the loading of FLEX.SYS the secondary boot loader keep an eye out for transfer address records. This record contains the jump address. After FLEX.SYS is loaded, it jumps to this address and the operating system takes over.
The new boot ROM and secondary boot loader were tested in the simulator:
The code for the secondary boot loader can be found here.