Difference between revisions of "6809 Second Processor"

From BeebWiki
Jump to: navigation, search
m (Sorted calls.)
m (Typo with OSQUIT.)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
[[Category:Second_Processors]]__NOTOC__
 
[[Category:Second_Processors]]__NOTOC__
 
A [[Second Processor|second processor]] for the BBC/Master containing a
 
A [[Second Processor|second processor]] for the BBC/Master containing a
Motorola 6809.
+
Motorola 6809/6309/6812.
  
 
The 6809 client MOS provides the basic system required to communicate with
 
The 6809 client MOS provides the basic system required to communicate with
 
the host computer. The BBC MOS entry block is implemented by using the BA/BS
 
the host computer. The BBC MOS entry block is implemented by using the BA/BS
signals to remap the hardware vectors to from &FFF0 to &FEF0.
+
signals to remap the hardware vectors from &FFF0 to &FEF0.
  
 
== MOS API Calls ==
 
== MOS API Calls ==
Line 14: Line 14:
 
On exit,  A, X, Y contain returned data
 
On exit,  A, X, Y contain returned data
 
           All addresses are big-endian, except where noted
 
           All addresses are big-endian, except where noted
           When an application starts it should call OSINIT which
+
           When an application starts it should call OS_INIT which
 
           returns MI if little-endian addresses are being used.
 
           returns MI if little-endian addresses are being used.
 
</pre>
 
</pre>
=== &FFF7 - OSCLI ===
+
=== &FFF7 - OS_CLI ===
 
<pre>On entry:              On exit:
 
<pre>On entry:              On exit:
 
X=>command string      A=Return value
 
X=>command string      A=Return value
 
</pre>
 
</pre>
=== &FFF4 - OSBYTE ===
+
=== &FFF4 - OS_BYTE ===
 
<pre>On entry:              On exit
 
<pre>On entry:              On exit
 
A=function              A=preserved
 
A=function              A=preserved
Line 28: Line 28:
 
                         Cy=returned carry flag
 
                         Cy=returned carry flag
 
</pre>
 
</pre>
=== &FFF1 - OSWORD ===
+
=== &FFF1 - OS_WORD ===
 
<pre>On entry:              On exit:
 
<pre>On entry:              On exit:
 
A=function              Control block updated
 
A=function              Control block updated
 
X=>control block        Y=returned line length for OSWORD 0
 
X=>control block        Y=returned line length for OSWORD 0
Text buffer address at X+0/1 with OSWORD 0 is big-endian
+
Text buffer address at X+0/1 with OSWORD 0 is big-endian.
 +
Contents of the OSWORD control block are as defined by the host.
 
</pre>
 
</pre>
=== &FFEE - OSWRCH ===
+
=== &FFEE - OS_WRCH ===
 
<pre>On entry:              On exit:
 
<pre>On entry:              On exit:
 
A=character            A=preserved
 
A=character            A=preserved
 
</pre>
 
</pre>
=== &FFEC - OSWRCR ===
+
=== &FFEC - OS_WRCR ===
 
<pre>On entry:              On exit:
 
<pre>On entry:              On exit:
 
                         A=13
 
                         A=13
 
</pre>
 
</pre>
=== &FFE7 - OSNEWL ===
+
=== &FFE7 - OS_NEWL ===
 
<pre>On entry:              On exit:
 
<pre>On entry:              On exit:
 
                         A=13
 
                         A=13
 
</pre>
 
</pre>
=== &FFE3 - OSASCI ===
+
=== &FFE3 - OS_ASCI ===
 
<pre>On entry:              On exit:
 
<pre>On entry:              On exit:
 
A=character            A=preserved
 
A=character            A=preserved
 
</pre>
 
</pre>
=== &FFE0 - OSRDCH ===
+
=== &FFE0 - OS_RDCH ===
 
<pre>On entry:              On exit:
 
<pre>On entry:              On exit:
 
                         A=character
 
                         A=character
 
                         Cy=carry flag
 
                         Cy=carry flag
 
</pre>
 
</pre>
=== &FFDD - OSFILE ===
+
=== &FFDD - OS_FILE ===
 
<pre>On entry:              On exit:
 
<pre>On entry:              On exit:
 
A=function              A=result
 
A=function              A=result
 
X=>control block        X=preserved
 
X=>control block        X=preserved
 
Filename address at X+0/1 is big-endian
 
Filename address at X+0/1 is big-endian
Control block addresses are big-endian unless indicated by OSINIT
+
Control block addresses are big-endian unless indicated by OS_INIT
 
</pre>
 
</pre>
=== &FFDA - OSARGS ===
+
=== &FFDA - OS_ARGS ===
 
<pre>On entry:              On exit:
 
<pre>On entry:              On exit:
 
A=function              A=result
 
A=function              A=result
Line 68: Line 69:
 
X=>data                X=preserved
 
X=>data                X=preserved
 
                         data updated
 
                         data updated
The data word is big-endian unless indicated by OSINIT
+
The data word is big-endian unless indicated by OS_INIT
 
</pre>
 
</pre>
=== &FFD7 - OSBPUT ===
+
=== &FFD7 - OS_BPUT ===
 
<pre>On entry:              On exit:
 
<pre>On entry:              On exit:
 
A=byte                  A=preserved
 
A=byte                  A=preserved
 
Y=handle                Y=preserved
 
Y=handle                Y=preserved
 
</pre>
 
</pre>
=== &FFD4 - OSBGET ===
+
=== &FFD4 - OS_BGET ===
 
<pre>On entry:              On exit:
 
<pre>On entry:              On exit:
 
                         A=byte
 
                         A=byte
Line 81: Line 82:
 
                         Cy=carry flag
 
                         Cy=carry flag
 
</pre>
 
</pre>
=== &FFD1 - OSGBPB ===
+
=== &FFD1 - OS_GBPB ===
 
<pre>On entry:              On exit:
 
<pre>On entry:              On exit:
 
A=function              A=preserved
 
A=function              A=preserved
 
X=>control block        Cy=carry flag
 
X=>control block        Cy=carry flag
Control block addresses are big-endian unless indicated by OSINIT
+
Control block addresses are big-endian unless indicated by OS_INIT
 
</pre>
 
</pre>
=== &FFCE - OSFIND ===
+
=== &FFCE - OS_FIND ===
 
<pre>On entry:              On exit:
 
<pre>On entry:              On exit:
 
A=function              A=handle
 
A=function              A=handle
Line 93: Line 94:
 
Y=handle
 
Y=handle
 
</pre>
 
</pre>
 +
=== &FFBF - OS_INIT  Initialise error handler and other environment settings ===
 +
<pre>On entry:
 +
  A=$00 to become the current program
 +
  A=$FF to just read the current settings
 +
On exit:
 +
  X  =address of BRKV
 +
  Y  =address of ESCFLG
 +
  DP =Direct Page
 +
  A,B=various
 +
  CC set from contents of A on return:
 +
  A.b7=1: little-endian filing system calls (CC=MI)
 +
  A.b7=0: big-endian filing system calls (CC=PL)
  
=== &FFBF - OSINIT Initialise error handler and other environment settings ===
+
This must be called by application code as part of its startup, before writing
<pre>                 On entry, A=0 to become the current program
+
anything to memory. Before making this call, code does not known where BRKV
                          A=$FF to just read the current settings
+
and ESCFLG are, as they can be anywhere in memory, and BREAK and errors will
                Returns X=>BRKV, Y=>ESCFLG, DP=>Direct Page, A,B=various
+
return to the previous caller.
                        CC set from contents of A on return
+
</pre>
                        A.b7=1: little-endian filing system calls (CC=MI)
+
=== &FFBC - OS_ERROR Generate an inline error ===
                        A.b7=0: big-endian filing system calls (CC=PL)
+
<pre>Can be used when not possible to generate an error with SWI. Entered with the
 +
address of the error block on the stack. Error blocks are:
 +
JSR OS_ERROR
 +
DB errornumber
 +
DB "error message"
 +
DB 0
 +
</pre>
 +
=== &FFB9 - OS_QUIT  Quit current process ===
 +
<pre>On entry:              On exit:
 +
A=return value
 +
Returns to any calling process. By default, returns to the Supervisor.
 +
</pre>
 +
=== &FFB3 - PRTEXT  Print inline text ===
 +
<pre>On entry:              On exit:
 +
                        A=$00
 +
                        X=corrupted
 +
Prints text immediately following the call, terminated with $00. Execution
 +
continues after the $00 terminator.
 +
</pre>
 +
=== &FFB0 - USERINT  Pass on FIRQs if not Tube FIRQ ===
  
                This must be called by application code as part of its
+
=== &FFAD - PR2HEX  Print X as 16-bit hex ===
                startup, before writing anything to memory. Before making
+
<pre>On entry:              On exit:
                this call, code does not known where BRKV and ESCFLG are,
+
                        A=corrupted
                as they can be anywhere in memory.
+
X=value to print        B=corrupted
 +
</pre>
 +
=== &FFAA - PRHEX  Print A as 8-bit hex ===
 +
<pre>On entry:              On exit:
 +
A=value to print        A=corrupted
 +
</pre>
 +
=== &FFA1 - SCANHEX  Scan line for hex number ===
 +
<pre>On entry:              On exit:
 +
X=>line to scan        X=>terminating character
 +
                        Y=number
 +
                        D=corrupted
 +
</pre>
 +
=== &FF9B - PRSTRING  Print text at X ===
 +
<pre>On entry:              On exit:
 +
X=>text to print,       X=>byte after terminating $00
 +
  terminated with $00  A=$00
 +
As X is returned pointing after the printed string, multiple strings
 +
can be printed with multiple calls to PRSTRING.
 
</pre>
 
</pre>
 
=== &FFBC - ERRJMP  ===
 
=== &FFB9 - CLICOM  ===
 
=== &FFB3 - PRTEXT  ===
 
=== &FFB0 - USERINT  ===
 
=== &FFAD - PR2HEX  ===
 
=== &FFAA - PRHEX    ===
 
=== &FFA7 - OSQUIT  ===
 
=== &FFA1 - SCANHEX  ===
 
=== &FF9B - PRSTRING ===
 
 
  
 
== See also ==
 
== See also ==

Latest revision as of 22:16, 8 September 2023

A second processor for the BBC/Master containing a Motorola 6809/6309/6812.

The 6809 client MOS provides the basic system required to communicate with the host computer. The BBC MOS entry block is implemented by using the BA/BS signals to remap the hardware vectors from &FFF0 to &FEF0.

MOS API Calls

Programs communicate with the kernal and MOS via an entry block at &FF80-&FFFF. Parameters are passed in the A, X and Y registers.

On entry, A, X, Y contain values to pass to system call
On exit,  A, X, Y contain returned data
          All addresses are big-endian, except where noted
          When an application starts it should call OS_INIT which
          returns MI if little-endian addresses are being used.

&FFF7 - OS_CLI

On entry:               On exit:
X=>command string       A=Return value

&FFF4 - OS_BYTE

On entry:               On exit
A=function              A=preserved
X=first parameter       X=returned word
Y=second parameter      Y=returned word DIV 256
                        Cy=returned carry flag

&FFF1 - OS_WORD

On entry:               On exit:
A=function              Control block updated
X=>control block        Y=returned line length for OSWORD 0
Text buffer address at X+0/1 with OSWORD 0 is big-endian.
Contents of the OSWORD control block are as defined by the host.

&FFEE - OS_WRCH

On entry:               On exit:
A=character             A=preserved

&FFEC - OS_WRCR

On entry:               On exit:
                        A=13

&FFE7 - OS_NEWL

On entry:               On exit:
                        A=13

&FFE3 - OS_ASCI

On entry:               On exit:
A=character             A=preserved

&FFE0 - OS_RDCH

On entry:               On exit:
                        A=character
                        Cy=carry flag

&FFDD - OS_FILE

On entry:               On exit:
A=function              A=result
X=>control block        X=preserved
Filename address at X+0/1 is big-endian
Control block addresses are big-endian unless indicated by OS_INIT

&FFDA - OS_ARGS

On entry:               On exit:
A=function              A=result
Y=handle                Y=preserved
X=>data                 X=preserved
                        data updated
The data word is big-endian unless indicated by OS_INIT

&FFD7 - OS_BPUT

On entry:               On exit:
A=byte                  A=preserved
Y=handle                Y=preserved

&FFD4 - OS_BGET

On entry:               On exit:
                        A=byte
Y=handle                Y=preserved
                        Cy=carry flag

&FFD1 - OS_GBPB

On entry:               On exit:
A=function              A=preserved
X=>control block        Cy=carry flag
Control block addresses are big-endian unless indicated by OS_INIT

&FFCE - OS_FIND

On entry:               On exit:
A=function              A=handle
X=>string or
Y=handle

&FFBF - OS_INIT Initialise error handler and other environment settings

On entry:
  A=$00 to become the current program
  A=$FF to just read the current settings
On exit:
  X  =address of BRKV
  Y  =address of ESCFLG
  DP =Direct Page
  A,B=various
  CC set from contents of A on return:
  A.b7=1: little-endian filing system calls (CC=MI)
  A.b7=0: big-endian filing system calls (CC=PL)

This must be called by application code as part of its startup, before writing
anything to memory. Before making this call, code does not known where BRKV
and ESCFLG are, as they can be anywhere in memory, and BREAK and errors will
return to the previous caller.

&FFBC - OS_ERROR Generate an inline error

Can be used when not possible to generate an error with SWI. Entered with the
address of the error block on the stack. Error blocks are:
JSR OS_ERROR
DB errornumber
DB "error message"
DB 0

&FFB9 - OS_QUIT Quit current process

On entry:               On exit:
A=return value
Returns to any calling process. By default, returns to the Supervisor.

&FFB3 - PRTEXT Print inline text

On entry:               On exit:
                        A=$00
                        X=corrupted
Prints text immediately following the call, terminated with $00. Execution
continues after the $00 terminator.

&FFB0 - USERINT Pass on FIRQs if not Tube FIRQ

&FFAD - PR2HEX Print X as 16-bit hex

On entry:               On exit:
                        A=corrupted
X=value to print        B=corrupted

&FFAA - PRHEX Print A as 8-bit hex

On entry:               On exit:
A=value to print        A=corrupted

&FFA1 - SCANHEX Scan line for hex number

On entry:               On exit:
X=>line to scan         X=>terminating character
                        Y=number
                        D=corrupted

&FF9B - PRSTRING Print text at X

On entry:               On exit:
X=>text to print,       X=>byte after terminating $00
   terminated with $00  A=$00
As X is returned pointing after the printed string, multiple strings
can be printed with multiple calls to PRSTRING.

See also

External links

Jgharston 16:53, 6 November 2009 (UTC) Jgharston (talk) 23:41, 30 January 2016 (UTC) Jgharston (talk) 00:44, 10 February 2022 (CET)