OSBYTE &D7

From BeebWiki
Revision as of 13:42, 28 October 2021 by Regregex (talk | contribs) (Description: describe)
Jump to: navigation, search

OSBYTE &D7 (215) - Enable/Disable Startup Message

   The Tube system replaces the startup computer message, and this call is
   used to do this. It can only be acted on by a paged ROM, since no other
   software has had a chance to load, only 2 bits are defined:
   b0=0=supress startup message
     =1=message as normal
   b7=0=computer hangs if there's a !Boot file error in the ROM filing system
     =0=computer hangs if there's a !Boot file error in the DISC filing system

Specification

 6502  On entry: On exit:
A =&D7 preserved
X =0 no startup message, hangup on RFS boot error
=1 no startup message, hangup on disc boot error
=128 startup message, hangup on RFS boot error
=129 startup message, hangup on disc boot error
previous value
Y =0 change both settings
=1 preserve error setting
=128 preserve message setting
=129 preserve both settings
contents of next location

Description

In OS 1.20 this variable resides at &0267 and is initialised to &81 on soft break, CTRL BREAK and power up. It is then interrogated later in the startup routine. The clients which may alter this variable in time for its use are, in chronological order:

  • Test hardware on the 1 MHz bus, which raises an interrupt and presents an entry vector at &FDFE
  • Code at the break intercept vector, set up by OSBYTE calls &F7, &F8 and &F9
  • Paged ROMs during service calls &FF, &01, &02, &FE and &03. Claiming service call &FE automatically disables the startup message.

A filing system ROM has the ability, during service call &03, to inhibit hangup on boot error for both itself and RFS though this is not recommended.

Bit 7 of the X register controls whether the startup message – BBC Computer plus optional memory display – appears on screen after a reset. The message is suppressed if bit 7 is clear and shown if it is set. Bit 7 is set by default. Third party hardware may clear the bit in order to print its own startup message instead, for instance.

Bit 0 of the X register controls the computer's response to errors raised with BRK instructions, before a language ROM installs its own error handler. Firstly the message attached to the error is displayed; next, the MOS behaves as follows:

  • If bit 0 is clear: an error raised while fetching the !BOOT executable from the ROM Filing System, or while !BOOT is running, causes the MOS to become unresponsive until BREAK is pressed. Any other early error causes the MOS to select the Cassette Filing System at 1200 baud, and either re-enter the previous language or enter the highest-priority language installed.
  • If bit 0 is set: an error raised while loading or running !BOOT from ROM leads to CFS selection and language entry; any other early error results in a hangup. Bit 0 is set by default.

The 'other' early errors encompass all errors raised by paged ROMs during startup service calls, including call &03 which installs a filing system and optionally runs a boot command from disc or other media; and the Language? error raised when the MOS finds no paged ROM that provides a system language. Clearing bit 7 in the latter case results in Language? recurring endlessly.

Booting from ROM only occurs if booting is requested, by the setting of keyboard link 5 or pressing SHIFT BREAK, and if no paged ROM claims the filing system initialisation service call &03.

Clearing both bits is a special case: after successfully running !BOOT from ROM, the MOS re-selects the Cassette Filing System regardless of any filing system installed by !BOOT. To inhibit this behaviour set X to another value, such as 2 – this adjustment is unofficial.

The Y register determines which, if any, of the previous settings shall be preserved. Setting bit 7 keeps the startup message display setting; setting bit 0 keeps the error response setting. Each bit set in Y should be cleared in X.

The call resturns the previous *FX 215 setting in X, and the value of the next location in Y.

Appearances in MOS 1.20

The OSBYTE &D7 variable is mentioned in the following places in the MOS 1.20 code (taken from Geoff Cox's disassembly):

   ...
   DB5F	LDX #&FE    ;issue call for Tube to explode character set etc.
   DB61	LDY &027A   ;Y=FF if tube present else Y=0
   DB64	JSR &F168   ;and make call via F168
   
   DB67	AND &0267   ;if A=&FE and bit 7 of 0267 is set then continue
   DB6A	BPL &DB87   ;else ignore start up message
   DB6C	LDY #&02    ;output to screen
   DB6E	JSR &DEA9   ;'BBC Computer ' message
   ...

JSR &F168 returns A=X=0 if the service call is claimed, A=X=&FF if unclaimed. Either setting *FX 215,n with n < 128 or claiming call &FE ensures that the startup message is not printed.

   ...
   DBA9	LDX #&D2    ;
   DBAB	LDY #&EA    ;
   DBAD	DEC &0267   ;decrement ignore start up message flag
   DBB0	JSR OSCLI   ;and execute */!BOOT
   DBB3	INC &0267   ;restore start up message flag
   DBB6	BNE &DBBE   ;if not zero then DBBE
   
   DBB8	LDA #&00    ;else A=0
   DBBA	TAX         ;X=0
   DBBB	JSR &F137   ;set tape speed
   ...

A short time later in the startup sequence; here, service call &03 has not been claimed and booting is requested, so the MOS has selected the ROM Filing System and is attempting to execute a boot file from ROM. The paired DEC and INC instructions invert bit 0 during the OSCLI call so that, if it had been clear, it is set while executing the command and hangs the machine in the event of reaching a BRK instruction. Bit 0 is set by default and so the MOS does not hang on a ROM boot error.

The MOS does not look at bit 7 during OSCLI, but the boot command will see a value one less than the proper value (modulo 256) while it is running.

On successful completion of the */!BOOT command, the INC instruction sets the Z flag according to the restored value at &0267. If the value is not zero then the following BNE branches to select a language ROM to enter. Otherwise *FX 215,0 is in effect: the MOS first selects the Cassette Filing System at 1200 baud.[1]

The MOS source code assembling the instruction at &DBB6 reads:

    BNE DNRFS ;[ALWAYS jump, do not reset filing system]

and so Acorn expected the equivalent of *FX 215,0 not to occur during startup. *FX 215,2 is an unofficial setting that preserves the filing system selection after booting from ROM.

   ...
   DC54	LDY #&00    ;Y=0 to point to byte after BRK
   DC56	JSR &DEB1   ;print message
   
   DC59	LDA &0267   ;if BIT 0 set and DISC EXEC error
   DC5C	ROR         ;occurs
   DC5D	BCS &DC5D   ;hang up machine!!!!
   ...

Lastly here is the start of the default BRK handler referenced by BRKV until a language replaces it with its own. Bit 0 decides whether to halt or continue: if it is set, the CPU loops forever; if clear, the current language is re-entered or a language is chosen from the available ROMs.

Effect

Two important errors affected by OSBYTE &D7 are:

  • File not found while searching for !BOOT in the RFS
  • Language? while searching for a language ROM.

Both are common errors in the BBC Micro: the former arising from keys being held down on BREAK and no bootable ROM present, the latter being raised if no language ROM is present.

To improve behaviour in such cases, Acorn opted to trap File not found and allow a language to start up regardless. Language? is unrecoverable in MOS 1.20 until a hardware change is made, and like other errors occurring so early the best response is to halt the machine.

Note that Language? behaves as a disc boot error for this purpose: enabling disc boot errors to proceed allows re-entry into the language selection routine, and with no language present, the micro enters an endless loop.

Reuse

Once startup is complete and a language installs its own BRK handler, all eight bits of this variable can be reused for temporary storage. If the default BRK handler may still be invoked, bits 7..1 remain free. The contents are destroyed on any type of reset and so accommodation for DEC &0267 or INC &0267 need not be made.

See Also

Jgharston 22:56, 26 May 2009 (UTC)
  1. The CPU actually falls through into the early BRK handler that also handles any error raised during service call &03 – which may mean that a filing system failed to set up properly, so the MOS falls back to CFS just in case.
    MOS 1.25, not expecting fall-through, prints a garbage error message at this point.