Microsoft REL file format
The REL format is generated by Microsoft's M80 and Digital Research's RMAC. The following description is from the Digital Research Programmer's Utilities Guide for CP/M+; comments in brackets refer to RMAC syntax.
M80 is capable of generating some record types which DR's LINK-80 can't handle. I don't know if these are present in the list.
REL files contain information encoded in a bit stream, which LINK-80 interprets as follows:
- If the first bit is a 0, then the next 8 bits are loaded according to the value of the location counter.
- If the first bit is a 1, then the next 2 bits are interpreted as
follows:
- 00
- special link item, defined below.
- 01
- program relative. The next 16 bits are loaded after being offset by the program segment origin.
- 10
- data relative. The next 16 bits are loaded after being offset by the data segment origin.
- 11
- common relative. The next 16 bits are loaded after being offset by the origin of the currently selected common block.
Special link items
A special item consists of:
- A 4-bit control field that selects one of 16 special link items described below.
- An optional value field that consists of a 2-bit address [type]
field and a 16-bit address field. The address type field is
interpreted as follows:
- 00
- absolute
- 01
- program relative
- 10
- data relative
- 11
- common relative
- An optional name field that consists of a 3-bit name count followed by the name in 8-bit ASCII characters.
The following special items are followed by a name field only:
- 0000
- entry symbol. The symbol indicated in the name field is defined in this module, so the module should be linked if the current file is being searched, as indicated by the S switch. [PUBLIC declaration]
- 0001
- select common block. Instructs LINK-80 to use the location counter associated with the common block indicated in the name field for subsequent common relative items.
- 0010
- program name. The name of the relocatable module.
- 0011
- unused.
- 0100
- unused.
The following special items are followed by a value field and a name field.
- 0101
- define common size. The value field determines the amount of memory reserved for the common block described in the name field. The first size allocated to a given block must be larger than or equal to any subsequent definitions for that block in other modules being linked.
- 0110
- chain external. The value field contains the head of a chain that ends with an absolute 0. Each element of the chain is replaced with the value of the external symbol described in the name field. [used by EXTRN etc]
- 0111
- define entry point. The value of the symbol in the name field is defined by the value field. [PUBLIC definition]
- 1000
- unused.
The following special items are followed by a value field only.
- 1001
- external plus offset. The following two bytes in the current segment must be offset by the value of the value field after all chains have been processed.
- 1010
- define data size. The value field contains the number of bytes in the data segment of the current module.
- 1011
- set location counter. Set the location counter to the value determined by the value field.
- 1100
- chain address. The value field contains the head of a chain that ends with an absolute 0. Each element of the chain is replaced with the current value of the location counter.
- 1101
- define program size. The value field contains the number of bytes in the program segment of the current module.
- 1110
- end module. Defines the end of the current module. If the value field contains a value other than absolute 0, it is used as the start address for the module being linked. That is, the current module is the main module. The next item in the file starts at the next byte boundary.
- 1111
- end file; has no value field or name field. This item follows the end module item in the last module in the file.