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. Diagramatic Address Summary --------------------------- +----+-------------------------------------------------------------------+ |Addr| Address High Word | |Low +--------+--------+--------+--------+--------+---------+-----+------+ |Word| FFFF | FFFE | FFFD | etc... | FFCx | FF8x | |<>FFxx| +----+--------+--------+--------+--------+--------+---------+- - -+------+ |FFFF| | | | | to | MOS | Reflections of MOS ROM | | |FF00| ROM | | | +----+--------+--------------------------+--------+---------+ | | |FEFF| Device | | Hidden |Reflect's| | | | to | I/O | Reflections of Device | MOS |of Device| | | |FC00| Space | I/O Space | ROM | I/O | | | +----+--------+--------------------------+--------+---------+ | | |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| | | Spare | | | | to | ROM | ROM | ROM | etc... | etc... | BBC B+ | | | |A000| 15 | 14 | 13 | | | RAM | | | +----+ | | | | +---------+ | | |9FFF| | | | | | MOS | | | | to | | | | | |Workspace| | | |8000| | | | | | RAM | | | +----+--------+--------+--------+--------+ +---------+ | | |7FFF| | Current| Shadow | | | | | to | | Screen | Screen | etc... | | | |3000| | Memory | Memory | | | | +----+ 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 slightly under a 4G address range for the language processor. Even just using &00xxxxxx for the language memory gives a 16M address space. 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. &FF8rxxxx -> Workspace RAM overlaid ROM space 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. &FFCyxxxx -> Hidden MOS ROM area Addressing summary ------------------ Bitmap of Address &0000-&7FFF &8000-&BFFF &C000-&FBFF &FC00-&FDFF address <&FFxxxxxx lang memory lang memory lang memory lang memory b23-b21+4 &FF0rxxxx main memory SROM/SRAM r FS RAM MOS ROM 0100 &FF2rxxxx main memory SROM/SRAM r FS RAM I/O 0110 &FF4rxxxx main memory VDU RAM MOS ROM MOS ROM 1000 &FF6rxxxx main memory VDU RAM MOS ROM I/O 1010 &FF8rxxxx main memory VDU RAM FS RAM MOS ROM 1100 &FFArxxxx main memory VDU RAM FS RAM I/O 1110 &FFCrxxxx main memory SROM/SRAM r MOS ROM MOS ROM 0000 &FFErxxxx main memory SROM/SRAM r MOS ROM I/O 0010 &FFFDxxxx shadow mem SROM/SRAM r MOS ROM I/O ||| &FFFExxxx display mem SROM/SRAM r MOS ROM I/O ||| &FFFFxxxx main memory SROM/SRAM r MOS ROM I/O ||| SROM/VDU-+|| MOS/FSRAM-+| Examples MOS/IO-----+ -------- 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 recognise 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 only recognises &FFxxxxxx for I/O memory and <>&FFxxxxxx for language memory. DFS cannot access screen memory natively. All other 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. Examination of the code shows this to be untrue. The BBC B+ recognises &FFFExxxx to access the currently displayed screen. Otherwise, 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 &FFrrxxxx for sideways ROMs and overlaid workspace. Example Programming ------------------- This function FNrm(), if used on the I/O processor, will read a byte from any paged or banked memory, except the hidden MOS ROM at &FC00-FEFF. DEFFNrm(!&F6):LOCAL Y%:Y%=?&F8+&40:IFY%AND&40:IF?&F7>&BF:?&F9=0 IF!&F6<0:IF?&F7>&7F OR Y%=&3E:=(USR&FFB9)AND&FF ELSE =?!&F6 The function FNwm(), if used on the I/O processor, will write a byte to screen or main memory. DEFPROCwm(!&D6,A%):IF!&D6<0:IF?&D8=&FE:CALL&FFB3:ENDPROC ELSE ?!D6=A%:ENDPROC If the passed address is &FFFExxxx it writes to the currently displayed screen memory, otherwise it writes to main memory. Version History --------------- 0.10 22-Oct-1987 Initial version 0.11 15-Jul-1989 Updated to conform with updated *MDump command.