Difference between revisions of "RISC-V Second Processor"

From BeebWiki
Jump to: navigation, search
(Initial page.)
 
(Updated.)
 
Line 9: Line 9:
 
== MOS API Calls ==
 
== MOS API Calls ==
 
Programs communicate with the kernal and MOS via the ECALL instruction.
 
Programs communicate with the kernal and MOS via the ECALL instruction.
Parameters are passed in registers A0 onwards.
+
Parameters are passed in registers A0 onwards with the call number in A7.
 +
ECALL call numbers are conventionally '''PLATFORM_BASE+CALL_NUMBER''' formed
 +
as &ppcccc. The Acorn BBC API calls are &AC0000+callnumber. Unknown calls
 +
are passed on to the Unknown_ECALL vector.
  
<pre>On entry, A0-A7 contain values to pass to ECALL call
+
<pre>On entry, A0-A6 contain values to pass to ECALL call
           A8=ECALL number
+
           A7=ECALL number
On exit,  A0-A7 contain returned data
+
On exit,  A0-A6 contain returned data
 +
          A7=preserved
 
           V=0 - no error occured
 
           V=0 - no error occured
           V=1 - error occured, R0=>error block
+
           V=1 - error occured, R0=>error block as per ECALL ACORN+&0F
 +
          Any registers not used in the call are preserved.
 
</pre>
 
</pre>
=== ECALL &00 - OS_QUIT ===
+
=== ECALL ACORN+&00 - OS_QUIT ===
<pre>On entry:           On exit:
+
<pre>On entry:             On exit:
A0=Return value
+
A0=Return value       Call does not return
 +
A7=&AC0000
 
</pre>
 
</pre>
  
=== ECALL &01 - OS_CLI ===
+
=== ECALL ACORN+&01 - OS_CLI ===
<pre>On entry:           On exit:
+
<pre>On entry:             On exit:
A0=>command string A0=Return value
+
A0=>command string   A0=Return value
 +
A7=&AC0001            A7=preserved
 
</pre>
 
</pre>
  
=== ECALL &02 - OS_BYTE ===
+
=== ECALL ACORN+&02 - OS_BYTE ===
<pre>On entry:           On exit
+
<pre>On entry:             On exit
A0=function         A0=preserved
+
A0=function           A0=preserved
A1=first parameter A1=returned word
+
A1=first parameter   A1=returned word
A2=second parameter A2=returned word DIV 256
+
A2=second parameter   A2=returned word DIV 256
                    Cy=returned carry flag
+
                      Cy=returned carry flag
 +
A7=&AC0002            A7=preserved
 
</pre>
 
</pre>
=== ECALL &03 - OS_WORD ===
+
=== ECALL ACORN+&03 - OS_WORD ===
<pre>On entry:           On exit:
+
<pre>On entry:             On exit:
A0=function         Control block updated
+
A0=function           Control block updated
A1=>control block   A1=returned line length for OSWORD 0
+
A1=>control block     A1=returned line length for OSWORD 0
 +
A7=&AC0003            A7=preserved
 
</pre>
 
</pre>
=== ECALL &04 - OS_WRCH ===
+
=== ECALL ACORN+&04 - OS_WRCH ===
<pre>On entry:           On exit:
+
<pre>On entry:             On exit:
A0=character       A0=preserved
+
A0=character         A0=preserved
 +
A7=&AC0004            A7=preserved
 
</pre>
 
</pre>
=== ECALL &05 - OS_NEWL ===
+
=== ECALL ACORN+&05 - OS_NEWL ===
<pre>On entry:           On exit:
+
<pre>On entry:             On exit:
                    A0=13
+
                      A0=13
 +
A7=&AC0005            A7=preserved
 
</pre>
 
</pre>
=== ECALL &06 - OS_RDCH ===
+
=== ECALL ACORN+&06 - OS_RDCH ===
<pre>On entry:           On exit:
+
<pre>On entry:             On exit:
                    A0=character
+
                      A0=character
                    Cy=carry flag
+
                      Cy=carry flag
 +
A7=&AC0006            A7=preserved
 
</pre>
 
</pre>
=== ECALL &07 - OS_FILE ===
+
=== ECALL ACORN+&07 - OS_FILE ===
<pre>On entry:           On exit:
+
<pre>On entry:             On exit:
A0=function         A0=onject type
+
A0=function           A0=onject type
A1=>filename         A1=preserved
+
A1=>filename         A1=preserved
A2=load address     A2=load address
+
A2=load address       A2=load address
A3=exec address     A3=exec address
+
A3=exec address       A3=exec address
A4=start address     A4=length
+
A4=start address     A4=length
A5=end address/attrs A5=attributes
+
A5=end address/attrs A5=attributes
 +
A7=&AC0007            A7=preserved
 
</pre>
 
</pre>
=== ECALL &08 - OS_ARGS ===
+
=== ECALL ACORN+&08 - OS_ARGS ===
<pre>On entry:           On exit:
+
<pre>On entry:             On exit:
A0=function         A0=result
+
A0=function           A0=result
A1=handle           A1=preserved
+
A1=handle             A1=preserved
A2=data             A2=data
+
A2=data               A2=data
 +
A7=&AC0008            A7=preserved
 
</pre>
 
</pre>
=== ECALL &09 - OS_BGET ===
+
=== ECALL ACORN+&09 - OS_BGET ===
<pre>On entry:           On exit:
+
<pre>On entry:             On exit:
                    A0=byte
+
                      A0=byte
A1=handle           A1=preserved
+
A1=handle             A1=preserved
                    Cy=carry flag
+
                      Cy=carry flag
 +
A7=&AC0009            A7=preserved
 
</pre>
 
</pre>
=== ECALL &0A - OS_BPUT ===
+
=== ECALL ACORN+&0A - OS_BPUT ===
<pre>On entry:           On exit:
+
<pre>On entry:             On exit:
A0=byte             A0=preserved
+
A0=byte               A0=preserved
A1=handle           A1=preserved
+
A1=handle             A1=preserved
 +
A7=&AC000A            A7=preserved
 
</pre>
 
</pre>
=== ECALL &0B - OS_GBPB ===
+
=== ECALL ACORN+&0B - OS_GBPB ===
<pre>On entry:           On exit:
+
<pre>On entry:             On exit:
A0=function         A0=result
+
A0=function           A0=result
A1=handle           A1=handle or cycle number
+
A1=handle             A1=handle or cycle number
A2=start address   A2=updated address
+
A2=start address     A2=updated address
A3=count           A3=updated count
+
A3=count             A3=updated count
A4=offset           A4=updated offset
+
A4=offset             A4=updated offset
                    Cy=carry flag
+
                      Cy=carry flag
 +
A7=&AC000B            A7=preserved
 
</pre>
 
</pre>
=== ECALL &0C - OS_FIND ===
+
=== ECALL ACORN+&0C - OS_FIND ===
<pre>On entry:           On exit:
+
<pre>On entry:             On exit:
A0=function         A0=handle
+
A0=function           A0=handle
A1=>string or handle
+
A1=>string or =handle A1=preserved
 +
A7=&AC000C            A7=preserved
 
</pre>
 
</pre>
=== ECALL &0D - OS_SYST ===
+
=== ECALL ACORN+&0D - OS_SYST ===
<pre>On entry:
+
<pre>On entry:            On exit:
  R0=subfunction
+
A0=subfunction
 +
A7=&AC000D            A7=preserved
 
</pre>
 
</pre>
  
=== ECALL &0E - OS_HANDLER ===
+
=== ECALL ACORN+&0E - OS_HANDLER ===
<pre>On entry:               On exit:
+
<pre>On entry:             On exit:
 
A0=handler number
 
A0=handler number
 +
A7=&AC000E            A7=preserved
 
</pre>
 
</pre>
=== ECALL &0F - OS_ERROR ===
+
=== ECALL ACORN+&0F - OS_ERROR ===
<pre>ECALL &0F is followed by the error block in memory:
+
<pre>ECALL &AC000F is followed by the error block in memory:
   ECALL 15
+
   ECALL &AC000F
   EQUW error
+
   EQUD error
 
   EQUS "error string"
 
   EQUS "error string"
 
   EQUB 0
 
   EQUB 0
Line 113: Line 133:
  
 
[[User:Jgharston|Jgharston]] ([[User talk:Jgharston|talk]]) 04:01, 6 September 2023 (CEST)
 
[[User:Jgharston|Jgharston]] ([[User talk:Jgharston|talk]]) 04:01, 6 September 2023 (CEST)
 +
[[User:Jgharston|Jgharston]] ([[User talk:Jgharston|talk]]) 18:32, 10 September 2023 (CEST)

Latest revision as of 18:32, 10 September 2023

(initial documentation)

An emulated Second Processor for the BBC/Master containing a RISC-V processor.

The RISC-V client MOS provides the basic system required to communicate with the host computer.

MOS API Calls

Programs communicate with the kernal and MOS via the ECALL instruction. Parameters are passed in registers A0 onwards with the call number in A7. ECALL call numbers are conventionally PLATFORM_BASE+CALL_NUMBER formed as &ppcccc. The Acorn BBC API calls are &AC0000+callnumber. Unknown calls are passed on to the Unknown_ECALL vector.

On entry, A0-A6 contain values to pass to ECALL call
          A7=ECALL number
On exit,  A0-A6 contain returned data
          A7=preserved
          V=0 - no error occured
          V=1 - error occured, R0=>error block as per ECALL ACORN+&0F
          Any registers not used in the call are preserved.

ECALL ACORN+&00 - OS_QUIT

On entry:             On exit:
A0=Return value       Call does not return
A7=&AC0000

ECALL ACORN+&01 - OS_CLI

On entry:             On exit:
A0=>command string    A0=Return value
A7=&AC0001            A7=preserved

ECALL ACORN+&02 - OS_BYTE

On entry:             On exit
A0=function           A0=preserved
A1=first parameter    A1=returned word
A2=second parameter   A2=returned word DIV 256
                      Cy=returned carry flag
A7=&AC0002            A7=preserved

ECALL ACORN+&03 - OS_WORD

On entry:             On exit:
A0=function           Control block updated
A1=>control block     A1=returned line length for OSWORD 0
A7=&AC0003            A7=preserved

ECALL ACORN+&04 - OS_WRCH

On entry:             On exit:
A0=character          A0=preserved
A7=&AC0004            A7=preserved

ECALL ACORN+&05 - OS_NEWL

On entry:             On exit:
                      A0=13
A7=&AC0005            A7=preserved

ECALL ACORN+&06 - OS_RDCH

On entry:             On exit:
                      A0=character
                      Cy=carry flag
A7=&AC0006            A7=preserved

ECALL ACORN+&07 - OS_FILE

On entry:             On exit:
A0=function           A0=onject type
A1=>filename          A1=preserved
A2=load address       A2=load address
A3=exec address       A3=exec address
A4=start address      A4=length
A5=end address/attrs  A5=attributes
A7=&AC0007            A7=preserved

ECALL ACORN+&08 - OS_ARGS

On entry:             On exit:
A0=function           A0=result
A1=handle             A1=preserved
A2=data               A2=data
A7=&AC0008            A7=preserved

ECALL ACORN+&09 - OS_BGET

On entry:             On exit:
                      A0=byte
A1=handle             A1=preserved
                      Cy=carry flag
A7=&AC0009            A7=preserved

ECALL ACORN+&0A - OS_BPUT

On entry:             On exit:
A0=byte               A0=preserved
A1=handle             A1=preserved
A7=&AC000A            A7=preserved

ECALL ACORN+&0B - OS_GBPB

On entry:             On exit:
A0=function           A0=result
A1=handle             A1=handle or cycle number
A2=start address      A2=updated address
A3=count              A3=updated count
A4=offset             A4=updated offset
                      Cy=carry flag
A7=&AC000B            A7=preserved

ECALL ACORN+&0C - OS_FIND

On entry:             On exit:
A0=function           A0=handle
A1=>string or =handle A1=preserved
A7=&AC000C            A7=preserved

ECALL ACORN+&0D - OS_SYST

On entry:             On exit:
A0=subfunction
A7=&AC000D            A7=preserved

ECALL ACORN+&0E - OS_HANDLER

On entry:             On exit:
A0=handler number
A7=&AC000E            A7=preserved

ECALL ACORN+&0F - OS_ERROR

ECALL &AC000F is followed by the error block in memory:
   ECALL &AC000F
   EQUD error
   EQUS "error string"
   EQUB 0

See also

Jgharston (talk) 04:01, 6 September 2023 (CEST) Jgharston (talk) 18:32, 10 September 2023 (CEST)