Built-in Module swi

swi

This module provides access to the RiscOS SWI interface. It provides a function swi that puts suitable values in the arm registers, calls the SWI and extracts values from registers.

As many SWIs manipulate blocks of memory a new object type is provided for handling blocks of memory and inserting and extracting values from them.

Errors are reported as exceptions; the usual exceptions are given for type, index and value errors, while errors reported by X versions of the system calls raise swi.error, described below.

Module swi defines the following data item:


\begin{excdesc}{error}
This exception is raised when an RiscOS X SWI returns a
R...
...i.error'}. The accompanying value is a
string returned by the SWI.
\end{excdesc}

It defines the following functions:


\begin{funcdesc}{swi}{name,descriptor,...}
Calls the swi given by \var{name} wit...
...0,''iisb;ii'',310,0x4b534154,pname,msgs)\end{verbatim}\ecode
\par
\end{funcdesc}


\begin{funcdesc}{block}{size \optional{\, initializer}}
Returns a new block of \...
...If there is no initializer
the content of the block is undefined.
\end{funcdesc}

The memory of a block is guaranteed not to move unless the block is deleted or resized.

Blocks support index and slice operations as for lists of integers, except that the block cannot change size, so assignments are truncated or padded as for initialization. Slices beyond the end of the block give index errors.


\begin{funcdesc}{register}{size,address}
Registers a prexisting memory block of ...
... be freed when the block
is deleted, or moved when it is resized.
\end{funcdesc}

Block items support the following data items and methods.


\begin{datadesc}{length}
The length of the block in bytes. Equal to \code{4*len(\var{block})}.
\end{datadesc}


\begin{datadesc}{start}
The start address of the memory block.
\end{datadesc}


\begin{datadesc}{end}
The address after the end of the memory block.
\end{datadesc}


\begin{funcdesc}{padstring}{string,padchar \optional{\,x,y}}
The string is copie...
...quired.
\var{x} and \var{y} default to 0 and \code{block.length}.
\end{funcdesc}


\begin{funcdesc}{tostring}{\optional{x,y}}
The bytes between \code{x} and \code{...
...string.
\var{x} and \var{y} default to 0 and \code{block.length}.
\end{funcdesc}


\begin{funcdesc}{nullstring}{\optional{x,y}}
The bytes between \code{x} and \cod...
...if any.
\var{x} and \var{y} default to 0 and \code{block.length}.
\end{funcdesc}


\begin{funcdesc}{ctrlstring}{\optional{x,y}}
The bytes between \code{x} and \cod...
...if any.
\var{x} and \var{y} default to 0 and \code{block.length}.
\end{funcdesc}


\begin{funcdesc}{bitset}{i,x,y}
\code{b.bitset(x,y)} is equivalent to \verb\vert b[i]=(b[i]&y)^x\vert.
\end{funcdesc}


\begin{funcdesc}{resize}{size}
Changes the size of the block. The new size is in...
...d the data in the block is
truncated or zero padded as neccesary.
\end{funcdesc}