Showing changes from revision #4 to #5:
Added | Removed | Changed
Entry | |
---|---|
R0–R9 | As required for target SWI |
R10 | Target SWI number |
Exit | |
---|---|
R0–R9 | As defined for target SWI |
R10 | Preserved |
The purpose of this call, is to call a run-time determined SWI.
This SWI allows a target SWI number to be determined at run time, and passed in a register. This removes the need for a common idiom of dynamic code, in language library SWI veneers for example. In an APCS-R library, use OS_CallASWIR12.
Note that this call is merely an alias for calling the target SWI. It has no entry/exit conditions of its own, except for the special use of R10. To call a target SWI with X bit set, use the X form of the SWI number in R10; there is no distinction between OS_CallASWI and XOS_CallASWI.
You cannot use this SWI to call itself, that is OS_CallASWI or OS_CallASWIR12, since there is no defined final target SWI in this case.
You cannot usefully call OS_BreakPt or OS_CallAVector, as it will corrupt the processor flags before entering the target SWI.
For future compatibility, you should always use this SWI in preference to any local construction for calling a SWI by number. For compatibility with older versions of RISC OS, a new CallASWI module will be made available.
Note that this SWI calling mechanism is almost certainly faster than any other alternative implementation, including the original _kernel_swi and _swix code contained in older versions of the SharedCLibrary. The new SharedCLibrary now simply uses OS_CallASWIR12 for _kernel_swi and _swix.
OS_CallASWI cannot be called from BASIC as BASIC only passes registers R0-R7 via its SYS instruction. It would not be useful anyway.
The CallASWI module provides this functionality for versions of RISC OS 3.70 or earlier.