Difference between revisions of "OSBYTE &A1"

From BeebWiki
Jump to: navigation, search
m (Tweeked title.)
m (typo)
 
Line 38: Line 38:
 
   DIM mem% max%
 
   DIM mem% max%
 
   FOR X%=0 TO max%
 
   FOR X%=0 TO max%
   mem%?X%=((USR&FFF4)AND&FF0000)DIV256
+
   mem%?X%=((USR&FFF4)AND&FF0000)DIV65536
 
   NEXT X%
 
   NEXT X%
  

Latest revision as of 23:05, 26 August 2024

OSBYTE &A1 (161): Read non-volatile 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 non-volatile 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)DIV65536
 NEXT X%

See Also

Jgharston 22:15, 26 May 2009 (UTC)