Difference between revisions of "OSBYTE &00"

From BeebWiki
Jump to: navigation, search
(Implementations)
m (.)
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:OSBYTE]]
 
[[Category:OSBYTE]]
===OSBYTE &00 (0) - Identify Host/Operating System===
+
{{PageTitle|OSBYTE &00 (0): Identify Host/Operating System}}
  On entry, X=0  - Generate error giving host and OS type
+
<div class="mw-widebody">
 +
  On entry, X=0  - Generate error number 247 giving host and OS type
 
           X<>0 - Return host/OS in X
 
           X<>0 - Return host/OS in X
 
   
 
   
 
  On exit,  X=host/OS type:
 
  On exit,  X=host/OS type:
 +
  0 Electron/Communicator  8 UNIX-type system                        24 CP/M-type system
 +
  1 BBC                    9 6809/6309 system    17 6809/6309 system
 +
  2 BBC B+                10 Apple/Mac/etc
 +
  3 Master 128
 +
  4 Master ET                                                        28 Commodore 64/128
 +
  5 Master Compact                                                    29 Texas Instruments calculator
 +
  6 Arthur or RISC OS                                                30 Amstrad CPC
 +
  7 Springboard                                                      31 Sinclair ZX Spectrum
 +
  Filesystem used:
 +
    :d.dir.file/ext          dir/file.ext            :d.dir.file/ext    d:file.ext
 
   
 
   
    0 Electron
+
On exit,  X=host/OS type:
    1 BBC
+
  32 (&20) IBM PC-type system (DOS, Windows, etc.)
    2 BBC B+
+
  43 (&2B) DEC DOS11/RSX11/RSTS/RT11 (DOS-style filesystem)
    3 Master 128
+
  57 (&39) 6809/6309 system with DOS-style filesystem
    4 Master ET
+
  Filesystem used:
    5 Master Compact
+
    d:\dir\file.ext
    6 Arthur or RISC OS
+
</div>
    7 Springboard
 
    8 UNIX or UNIX-type system
 
  28 Commodore 64/128
 
  29 Texas Instruments calculator
 
  30 Amstrad CPC
 
  31 Sinclair ZX Spectrum
 
>=32 IBM PC-type system (DOS, Windows, etc.)
 
  
 
==Implementations==
 
==Implementations==
Line 27: Line 31:
 
second processor will always be told what the I/O host is regardless of
 
second processor will always be told what the I/O host is regardless of
 
what the host is and what the second processor is.
 
what the host is and what the second processor is.
 +
 +
80x86 BBC BASIC running on DOS and Windows returns 32 as a side effect
 +
of reading the character under the cursor. Properly written code that
 +
calls OSBYTE 0 will know to do so in a manner that ensures this occurs.
 +
Normally this just means calling OSBYTE 0 at program startup before
 +
outputting anything.
 +
 +
When writing a host, OSBYTE 0,0 should generate an error with the text
 +
in the form:
 +
* "MOS NAME a.bc"
 +
* or "MOS NAME a.bc (dd Mmm yyyy)"
 +
* or "MOS NAME a.bc (dd Mmm yyyy) additional info"
  
 
==Platform capabilities==
 
==Platform capabilities==
Line 51: Line 67:
 
* [[Multiplatform programming]]
 
* [[Multiplatform programming]]
  
 +
----
 
[[User:Jgharston|Jgharston]] 22:41, 6 September 2007 (BST)
 
[[User:Jgharston|Jgharston]] 22:41, 6 September 2007 (BST)
 +
[[User:Jgharston|Jgharston]] ([[User talk:Jgharston|talk]]) 06:35, 12 April 2020 (CEST)

Latest revision as of 21:14, 30 August 2024

OSBYTE &00 (0): Identify Host/Operating System
On entry, X=0  - Generate error number 247 giving host and OS type
          X<>0 - Return host/OS in X

On exit,  X=host/OS type:
  0 Electron/Communicator  8 UNIX-type system                         24 CP/M-type system
  1 BBC                    9 6809/6309 system     17 6809/6309 system
  2 BBC B+                10 Apple/Mac/etc
  3 Master 128
  4 Master ET                                                         28 Commodore 64/128
  5 Master Compact                                                    29 Texas Instruments calculator
  6 Arthur or RISC OS                                                 30 Amstrad CPC
  7 Springboard                                                       31 Sinclair ZX Spectrum
 Filesystem used:
    :d.dir.file/ext          dir/file.ext            :d.dir.file/ext     d:file.ext

On exit,  X=host/OS type:
 32 (&20) IBM PC-type system (DOS, Windows, etc.)
 43 (&2B) DEC DOS11/RSX11/RSTS/RT11 (DOS-style filesystem)
 57 (&39) 6809/6309 system with DOS-style filesystem
 Filesystem used:
    d:\dir\file.ext

Implementations

Early documentation refers to OSBYTE 0 as returning the OS version. As more systems were developed, it became more correct to refer to it returning a value indicating the host. For example, code running on a second processor will always be told what the I/O host is regardless of what the host is and what the second processor is.

80x86 BBC BASIC running on DOS and Windows returns 32 as a side effect of reading the character under the cursor. Properly written code that calls OSBYTE 0 will know to do so in a manner that ensures this occurs. Normally this just means calling OSBYTE 0 at program startup before outputting anything.

When writing a host, OSBYTE 0,0 should generate an error with the text in the form:

  • "MOS NAME a.bc"
  • or "MOS NAME a.bc (dd Mmm yyyy)"
  • or "MOS NAME a.bc (dd Mmm yyyy) additional info"

Platform capabilities

Over time the OSBYTE 0 return value has evolved to become a bitmap representing the capabilities of the host system, primarily of the file system structure.

  • %000x0xxx Filenames are directory.filename/extension, eg BBC, RISC OS
  • %000x1xxx Filenames are directory/filename.extension, eg Unix, CP/M
  • %nnnxxxxx Filenames are directory\filename.extension, eg DOS, Windows

This can also be represented as:

  • %000x0xxx Directory seperator is '.'
  • %000x1xxx Directory seperator is '/'
  • %nnnxxxxx Directory seperator is '\'
  • %000x0xxx Extension seperator is '/'
  • %nnnxnxxx Extension seperator is '.'

This allow programs to use code similar to the following:

  A%=0:X%=1:os%=((USR&FFF4)AND&FF00)DIV256
  d$=".":s$="/":IF(os%AND-24):d$="/":s$=".":IF(os%AND-32):d$="\"
  filename$=dir$+d$+name$+s$+ext$

See also


Jgharston 22:41, 6 September 2007 (BST) Jgharston (talk) 06:35, 12 April 2020 (CEST)