OSBYTE &8F

From BeebWiki
Jump to: navigation, search

OSBYTE &8F (143) - Issue SWR Service Request (on exit Y=response to request if appropriate)

   X=request number
   Y=parameter to pass (varies depending on the request number)

Specification

 6502  On entry: On exit:
A =&8F preserved
X Service request code =0 service call claimed
<>0 service call not claimed
Y Parameter to service call Result from service call
Note

Certain service calls such as &01 and &02 return a result in Y without claiming the call.
Other unclaimed calls preserve Y, provided that all paged ROMs behave correctly.

Side effect

On exit ROMSEL is left set to the current sideways ROM slot number stored in location &F4. J.G.Harston points out that any program may page in a sideways ROM by storing the desired slot number there and immediately calling OSRDSC, but it is also possible to combine a service call issue with a bank switch using the same technique:

   		\A contains ROM slot number to switch to
   LDY #&FF	\service call parameter = &FF, indicate OSRDSC available
   LDX #&0E	\service call number = &0E, RFS data poll
   STA &F4	\set new current ROM number
   LDA #&8F	\OSBYTE call number = &8F, issue service call
   JSR OSBYTE	\issue service call
   		\slot number in A on entry is now selected

OSBYTE &8F provides pure ROM paging in OS 1.00, where OSRDSC is not available:

   		\Y contains ROM slot number to switch to
   LDX #&00	\service call number = &00, null call
   LDA #&8F	\OSBYTE call number = &8F, issue service call
   STY &F4	\set new current ROM number
   JSR OSBYTE	\issue service call
   		\slot number in Y on entry is now selected

The OS call encapsulates differences between platforms (particularly on the Electron) and improves revolving bookcase routines within sideways ROMs, which no longer need to wait for the chip select lines to stabilise after switching banks. Note that in such routines, after location &F4 has been updated, an interrupt service may switch banks early and so all instructions between STA &F4 and JSR OSBYTE inclusive must be the same in the source and destination banks.

See Also

Jgharston 21:26, 26 May 2009 (UTC)