OSBYTE &A1

From BeebWiki
Revision as of 17:13, 31 October 2010 by Jgharston (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Read configuration RAM/EEPROM

 On entry:
   X=byte to read or 255 for to read configuration RAM/EEPROM size
 On exit:
   X corrupted or &FF if no configuration RAM/EEPROM support
   Y=byte read or configuration RAM/EEPROM size

OSBYTE &A1 reads a byte from the configuration RAM/EEPROM. There are typically 50 locations but implementations can have more. The Master 128 uses 50 bytes of nonvolatile CMOS RAM, the Master Compact uses a 128-byte or a 256-byte EEPROM, the Master Extension ROM for the BBC B uses a block of memory or a file on disk.

The presence and size of the configuration RAM/EEPROM can be read with the following code:

 A%=161:X%=255:Y%=49:U%=USR&FFF4
 X%=(U%AND&FF00)DIV256
 Y%=(U%AND&FF0000)DIV65536

This will set X% to <>&FF if configuration RAM/EEPROM access via OSBYTE &A1 exists or &FF if absent. It will set Y% to the configuration RAM/EEPROM size minus 1, typically 49, 127 or 255, or 0 for not present.

The following code will read all the configuration data.

 A%=161:X%=255:Y%=49
 max%=((USR&FFF4)AND&FF0000)DIV65536
 DIM mem% max%
 FOR X%=0 TO max%
 mem%?X%=((USR&FFF4)AND&FF0000)DIV256
 NEXT X%

See Also

Jgharston 22:15, 26 May 2009 (UTC)