RISC-V Second Processor

From BeebWiki
Jump to: navigation, search

(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)