Previous page: ROM Structure Next page:
BBC ROMs   Service Events

Every ROM has a header at the start containing useful information to the OS about the ROM including its name, version and copyright notice. Most texts from the '80s described the version string as coming after the copyright string, however inspection of various standard system ROMs including BASIC 2, BASIC 4, View, ViewSheet and ADFS shows that the version string is actually found before the copyright string and that is how it is described here.

The actual decoding of the first 6 bytes for BASIC ROMs does not conform to the following and OS ROMs do not use a standard ROM header. Otherwise, all ROMs conform to the following and start at address &8000.

The meaning of the header bytes are:
Number of BytesMeaning
3 First byte is a JMP op-code (&4c) and the next two are the location of the start of code for a language ROM. If this is not a language ROM, these three bytes are zeros.
3 First byte is a JMP op-code (&4c) and the next two are the location of the start of the service routine. All ROMs except BASIC ROMs must have a service routine (BASIC ROMs will have three zeros here).
1 The ROM type (see below).
1 The offset of the zero byte just before the copyright notice.
1 The ROM version.
variable The ROM title (printed out by the "*ROMS" command).
1 A zero to mark the end of the title.
variable The ROM version string.
1 A zero to mark the end of the version and start of the copyright string. The offset of this byte is stored in the 8th byte of the ROM (above).
variable The copyright string. Must start with the three characters "(C)" to be a valid ROM.
1 A zero to mark the end of the copyright string.
4 if present,
otherwise 0
If the type byte (above) indicates this ROM has a Tube relocation address, then these four bytes contain that address. Otherwise, they are not present.

The top 4 bits in the type byte should be set as follows:
BitMeaning
7 ROM has a service routine (should always be set)
6 ROM is a language
5 ROM contains code assembled for a co-processor (and so a Tube relocation address is present)
4 Not used
The bottom 4 bits are:
ValueMeaning
0000 65C12 or 6502 BASIC
0001 Reserved
0010 65C12 or 6502 code other than BASIC (eg. machine code)
0011 68000 code
1000 Z80 code
1001 32016 code
1010 Reserved
1011 80186 code
1100 80286 code
1101 Reserved
It is not clear what happens if other values are set. Thus a service ROM will have type &82 and a language ROM will have type &c2 (as it must provide a service routine, too).

The term "language ROM" does not necessarily mean the ROM contains a language. Rather, it means the ROM has code which makes it the current interactive system. In this way, View (the word processor) and ViewSheet (the spreadsheet application) are both considered languages as once you enter them, all interaction is with them until another language ROM is selected.

A service ROM is one which responds to a certain set of signals sent by the OS. These include indication that the system has been reset, signals inviting ROM code to request chunks of memory, etc. Also, all the "star" commands are implemented in this way. When the user types "*HELP", a signal is sent to each ROM's service routine for it to respond if it wishes. Similarly, any other "star" command is implemented in this way except "*BASIC" which is implemented by the OS and causes it to start the language routine of the BASIC ROM (which is why the BASIC ROM doesn't need a service routine). More of these signals shortly.

The standard convention for version strings is to have a single digit followed by a dot and then two further digits, however there is no requirement to stick to this format, though this convention will be used by all the examples here. The ROM version byte is not related to the version string. I have no idea what the distinction is so please don't ask. The version byte will be displayed by certain utilities (for example, "*ROMS" may use this on some systems).

A copyright string is required and must start with the three characters "(C)" or it will not be initialised by the OS and it will not be accessible.

The Tube address if present is the address the ROM will be loaded at across the Tube on a second processor. If the ROM has a relocate address, then it should be assembled with this address as its base address and not &8000 and for the chip that is located across the Tube rather than 6502 if that chip is different (say a Z80 coprocessor).

After the header is the actual executable machine code of the ROM. If the ROM is started as a language, then execution starts from the language address. The service routine is started by the OS to respond to various signals from time to time. Once started as a language, the ROM is free to opperate as necessary until such a time as another language ROM becomes active. In this way, the "language" might be a word processor, a programming language interface, or even a game and thus the coding of the language routine is outside the scope of this article. The following pages describe the various service events the OS sends to ROMS and how a ROM can respond. This will include responding to a particular keyword and restarting the ROM as a language (this is what the View ROM does when it detects the "*WORD" command, for example, and is the usual way for a language routine to start).


Previous page: ROM Structure Next page:
BBC ROMs   Service Events