BBC Memory Addressing Methods ============================= File: Docs.Comp.BBC.MemAddrs - Update: 0.11 Author: J.G.Harston -- Date: 15-07-1989 Many BBC commands and OS calls use 32-bit address parameters to refer to areas of memory. An example is the *SAVE command, and the OSFILE entry point that it calls. The memory addresses specify which area of memory to use, the most common example being &FFFFxxxx refering to I/O memory and <>&FFFFxxxx to refering to language memory. Some systems also allow the use of &FFFExxxx to refer to the screen memory. With sideways ROM and RAM banks and additional workspace memory in Master series computers, there is more memory available that many addressing schemes miss out. This document clarifies how these addresses should be used to reference various areas of an Acorn computer system's memory. Address Summary --------------- +----+-------------------------------------------------------------------+ |Addr| Address High Word | |Low +--------+--------+--------+--------+--------+---------+-----+------+ |Word| FFFF | FFFE | FFFD | FFFC | etc... | FF7F | |<>FFxx| +----+--------+--------+--------+--------+--------+---------+- - -+------+ |FFFF| | | | | to | MOS | Reflections of MOS ROM | | |FF00| ROM | | | +----+--------+-----------------------------------+---------+ | | |FEFF| Device | | Hidden | | | | to | I/O | Reflections of Device I/O Space | MOS | | | |FC00| Space | | ROM | | | +----+--------+-----------------------------------+---------+ | | |FBFF| | | | | to | | | | |E000| | | | +----+ MOS | Reflections of MOS ROM +---------+ | | |DFFF| ROM | | Private | | L | | to | | |Workspace| | a M | |C000| | | RAM | | n e | +----+--------+--------+--------+--------+--------+---------+ | g m | |BFFF| | | | | | | u o | | to | | | | | | | a r | |B000| | | | | | | g y | +----+ | | | | +---------+ | e | |AFFF|Sideways|Sideways|Sideways|Sideways| | Spare | | | | to | ROM | ROM | ROM | ROM | etc... | BBC B+ | | | |A000| 15 | 14 | 13 | 12 | | RAM | | | +----+ | | | | +---------+ | | |9FFF| | | | | | MOS | | | | to | | | | | |Workspace| | | |8000| | | | | | RAM | | | +----+--------+--------+--------+--------+--------+---------+ | | |7FFF| | Current| Shadow | Shadow | | | | | to | | Screen | Screen | Screen | etc... | | | |3000| | Memory | Bank 1 | Bank 2 | | | | +----+ Main +--------+--------+--------+--------+ | | |2FFF| Memory | | | | to | | Reflections of Main Memory | | |0000| | | | +----+--------+---------------------------------------------------+------+ Coprocessor Memory ------------------ With the Tube system a coprocessor can be added, increasing the memory and also allowing different software to be run. This brings the concept of I/O memory and language memory. I/O memory is the memory that the host machine has, where the actual hardware such as the screen and disk interfaces connect to. Language memory is the memory that the language or main application uses. With no coprocessor connected, language memory is the same as I/O memory, with the screen having to share space with the applications. I/O memory was initially refered to with &FFFFxxxx addresses, and language memory with <>&FFFFxxxx addresses. However, with more memory in the I/O system, such as shadow screen memory at &FFFExxxx, other I/O addresses started being used. The scheme is now that I/O memory is at &FFxxxxxx and language memory at <>&FFxxxxxx. This still gives an almost 2G address range for the language processor. Even just using &00xxxxxx for the language memory gives a 16M address space. &FFxxxxxx -> I/O memory &FExxxxxx to -> Undefined, defaults to language memory &80xxxxxx &7Fxxxxxx to -> Language memory &01xxxxxx &00xxxxxx -> Language memory Main/Screen Memory ------------------ For addresses in the range &xxxx0000 to &xxxx7FFF, which can be tested for by checking bit 15 of the address. &FFFFxxxx -> I/O memory &FFFExxxx -> Currently displayed screen &FFFDxxxx -> Shadow screen bank 1 &FFFCxxxx -> Shadow screen bank 2, if any, ... etc. Sideways ROMs ------------- For addresses in the range &xxxx8000 to &xxxxBFFF, which can be tested for by checking bit 15 and bit 14 of the address. &FFFrxxxx -> Sideways ROM number r MOS ROM Area ------------ For addresses in the range &xxxxC000 to &xxxxFFFF, which can be tested for by checking bit 15 and bit 14 of the address &FFFyxxxx -> MOS ROM Workspace RAM ------------- Workspace RAM on the Master series appears over part of the sideways ROM area at &8000 to &9FFF and over part of the MOS ROM area at &C000 to &DFFF; and on the BBC B+ there is 12K left over from the shadow screen at &8000 to &AFFF. For programming purposes it is easier to check for address ranges of &8000 to &BFFF and &C000 to &FFFF. The hardware switches the correct memory areas into the memory map. &FFEyxxxx -> Workspace RAM Hidden MOS ROM -------------- 'Underneath' the I/O area in FRED, JIM and SHELIA at &FC00 to &FExx there is a hidden area of MOS ROM. On the Master series computers this area can actually be switched into memory and accessed. On most machines it contains a list of acknowledgements, but MOS 3.50 puts some startup code there. &FFEyxxxx -> Hidden MOS ROM area Examples -------- Using the JGH *MDump command, doing: *MDUMP FFFC8000+4000 will display a memory dump of ROM number 12. Using a compatible filing system, doing: *SAVE SCREEN FFFE3000+5000 will save the screen memory to a file 'SCREEN'. Implementation and Compatability -------------------------------- J.G.Harston's *MDump and *MEdit commands recognises addresses fully. HADFS recognises &FFFFxxxx, &FFFExxxx and &FFFDxxxx to select screen memory, and <>&FFxxxxxx for language memory. BBC B filing systems only recognise &FFFFxxxx for I/O memory and <>&FFFFxxxx for language memory. DFS 2.xx onwards recognise &FFFExxxx for screen memory. All Master filing systems recognise &FFFExxxx for screen memory. Documentation claims that OSWORD 5/6 (Read/Write I/O memory) recognises &FFFExxxx for screen memory on systems with shadow screens, ie B+ onwards. Examination of the code shows this to be untrue. Whatever currently selected screen memory and sideways ROM/RAM memory is accessed. Some implementations of OSWORD &FF (Transfer memory between host and Z80 coprocessor) recognise &FFFExxxx for screen memory and &FFFrxxxx for sideways ROMs. Example Programming ------------------- 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 EOR &F0:IF?&F8<&80:IF?&F7>&BF:?&F9=0 IF!&F6<0:IF?&F7>&7F OR Y%=&E:=(USR&FFB9)AND&FF ELSE =?!&F6 DEFFNwm(!&D6,A%):ENDPROC Version History --------------- 0.10 22-Oct-1987 Initial version 0.11 15-Jul-1989 Updated to conform with updated *MDump command.