Difference between revisions of "OSRDSC"

From BeebWiki
Jump to: navigation, search
m (Side effect: sp)
(Side effect: substitute in OS 1.00)
Line 49: Line 49:
 
     STA &F4 \or STX or STY
 
     STA &F4 \or STX or STY
 
     JSR OSRDSC
 
     JSR OSRDSC
 +
[[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 A on entry is now selected
  
 
The OS call encapsulates differences between platforms (particularly on the
 
The OS call encapsulates differences between platforms (particularly on the

Revision as of 20:45, 20 January 2022

Fetches a byte from paged ROM or display memory.

Specification

On entry:
Y   = Slot number of ROM to be paged in
 ?&F6   = LSB of address to be read
 ?&F7   = MSB of address to be read
On exit:
A   = contents of address
X,Y,C   = undefined (all implementations: X=current ROM, Y=&00 (BBC/Electron) Y=preserved (Master))

Fetches a byte from an address in paged ROM or the current display memory (in main or shadow RAM) and returns it in A. The address to be read is given in locations &F6 (low byte) and &F7 (high byte), and the paged ROM slot to read from is given in Y. If the address lies outside the paged ROM space then the value of Y is irrelevant.

When a paged ROM receives service call &0E, locations &F6 and &F7 are already set up with an appropriate address, and the ROM slot number can be derived from location &F5. If Y=&FF on entry to service call &0E then the operating system provides OSRDRM, so RFS ROMs can quickly serve data bytes on one another's behalf by calling OSRDRM as long as the MOS supports it.

MOS 2.00 introduces a counterpart routine, OSWRSC, to write a byte to the screen.

Side effect

On exit ROMSEL is left set to the current sideways ROM slot number stored in location &F4; the switch is performed by the internal STXROM routine, which OSRDSC effectively exposes by falling through into it.

J.G.Harston points out that any program may page in a sideways ROM by storing the desired slot number there and immediately calling &FFB9:

   STA &F4	\or STX or STY
   JSR OSRDSC

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 A 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.

Calling from BBC BASIC

  • BASIC does not call OSRDSC

Entry points

  • BBC BASIC Entry Address: none
  • 6502 Entry Address: &FFB9
  • Z80 Entry Address: none
  • 6809 Entry Address:
  • 80x86 Entry Address: none
  • 32000 Entry Address: none
  • PDP-11 Entry Address: none
  • ARM Entry Address: none

Implementation

The call is absent in MOS 0.10 and MOS 1.00 and service call &0E enters paged ROMs with Y<>&FF. The entry point exists in MOS 1.20 and is known as OSRDRM but is undocumented, and accesses paged ROMs and main memory only. It is documented in MOS 2.00 as OSRDSC and reads from the specified paged ROM/SRAM and the currently displayed screen memory. On the Master series the call reads from whichever screen memory is being accessed by the VDU.

OSRDRM/OSRDSC is not implemented on non-6502 platforms and BBC BASIC does not emulate its entry point.

Coding

The function FNrm(), if used on the I/O processor, will read a byte from any banked memory, except the hidden MOS ROM at &FC00-FEFF.

   DEFFNrm(!&F6):LOCAL Y%:Y%=?&F8+&40:IFY%>&BF:IF?&F7>&BF:?&F9=0
   IF!&F6<0:IF?&F7>&7F OR Y%=&3E:=(USR&FFB9)AND&FF ELSE =?!&F6

The passed address reads the following memory:

 Address    &0000-&2FFF  &3000-&7FFF  &8000-&8FFF  &9000-&BFFF  &C000-&DFFF  &E000-&FFFF
<&FFxxxxxx  main memory  main memory  current ROM  current ROM    FS RAM       MOS ROM 
 &FF0rxxxx  main memory  main memory  SROM/SRAM r  SROM/SRAM r    MOS ROM      MOS ROM
 &FF4rxxxx  main memory  main memory  VDU RAM      SROM/SRAM r    MOS ROM      MOS ROM
 &FF8rxxxx  main memory  main memory  VDU RAM      SROM/SRAM r    FS RAM       MOS ROM
 &FFFrxxxx  main memory  main memory  SROM/SRAM r  SROM/SRAM r    MOS ROM      MOS ROM
 &FFFExxxx  main memory  display mem  SROM/SRAM r  SROM/SRAM r    MOS ROM      MOS ROM
 &FFFFxxxx  main memory  main memory  SROM/SRAM r  SROM/SRAM r    MOS ROM      MOS ROM

-- beardo 23:20, 5 October 2007 (BST) Jgharston (talk) 04:25, 29 March 2015 (UTC)