Difference between revisions of "OSBYTE &A1"

From BeebWiki
Jump to: navigation, search
m (1 revision)
(Clarified return values.)
Line 1: Line 1:
 
[[Category:OSBYTE]]
 
[[Category:OSBYTE]]
==Read configuration RAM/EEPROM==
+
==Read non-volatile configuration memory==
 
   On entry:
 
   On entry:
     X=byte to read or 255 for to read configuration RAM/EEPROM size
+
     X=offset to byte to read or 255 to read memory size
 
   On exit:
 
   On exit:
     X corrupted or &FF if no configuration RAM/EEPROM support
+
     If unsupported: X=&FF
     Y=byte read or configuration RAM/EEPROM size
+
                    Y=preserved
 +
     If offset within non-volative memory exists:
 +
                    X=absolute offset within memory
 +
                    Y=byte read
 +
    If offset within non-volatile memory does not exist (past last location):
 +
                    X=preserved
 +
                    Y=preserved
 +
    If reading size of non-volatile memory:
 +
                    X=&FF (ie, preserved)
 +
                    Y=maximum offset (ie size-1), or zero if call supported and
 +
                    no memory present, or preserved if call unsupported
  
OSBYTE &A1 reads a byte from the configuration RAM/EEPROM. There are typically
+
OSBYTE &A1 reads a byte from non-volatile memory used to store configuration data.
50 locations but implementations can have more. The Master 128 uses 50 bytes
+
There are typically 50 locations but implementations can have more. The Master 128
of nonvolatile CMOS RAM, the Master Compact uses a 128-byte or a 256-byte EEPROM,
+
uses 50 bytes of nonvolatile CMOS RAM, the Master Compact uses a 128-byte or a
the Master Extension ROM for the BBC B uses a block of memory or a file on disk.
+
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 non-volatile memory can be read with the following code:
 +
 
 +
  A%=161:X%=0:U%=USR&FFF4
 +
  X%=(U%AND&FF00)DIV256
 +
This will set X% to <>&FF if non-volatile memory access via OSBYTE &A1 exists, or &FF if absent.
  
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
 
   A%=161:X%=255:Y%=49:U%=USR&FFF4
  X%=(U%AND&FF00)DIV256
 
 
   Y%=(U%AND&FF0000)DIV65536
 
   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.
+
This will set Y% to the memory size minus 1, typically 49, 127 or 255, or 0 for not present.
  
 
The following code will read all the configuration data.
 
The following code will read all the configuration data.

Revision as of 22:45, 26 August 2024

Read non-volatile configuration memory

 On entry:
   X=offset to byte to read or 255 to read memory size
 On exit:
   If unsupported: X=&FF
                   Y=preserved
   If offset within non-volative memory exists:
                   X=absolute offset within memory
                   Y=byte read
   If offset within non-volatile memory does not exist (past last location):
                   X=preserved
                   Y=preserved
   If reading size of non-volatile memory:
                   X=&FF (ie, preserved)
                   Y=maximum offset (ie size-1), or zero if call supported and
                   no memory present, or preserved if call unsupported

OSBYTE &A1 reads a byte from non-volatile memory used to store configuration data. 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 non-volatile memory can be read with the following code:

 A%=161:X%=0:U%=USR&FFF4
 X%=(U%AND&FF00)DIV256

This will set X% to <>&FF if non-volatile memory access via OSBYTE &A1 exists, or &FF if absent.

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

This will set Y% to the memory 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)