AcornSearch - Acorn and RISC OS information searching
RISC OS Search
containing
"Nutty quip goes here!"
Home  |  About  |  Filebase Archive  |  StrongHelp Manuals  |  Newsgroups  |  Module Database
=>     R1 =     service number
     R12 =     pointer to private word for module instantiation
     R13 =     pointer to stack

<=     R1 =     0 if service is being claimed, preserved otherwise
     R0,R2-R8 altered depending on service call if claimed
     R12 may be corrupted
     Other registers should be preserved if they are not being used to return values

This entry is called when a service call is issued. Service call code must be reentrant.

Since service calls are made very often they can cause significant slow-downs if not handled in a speed-conscious manner.  It is recommended that on reception of service calls that are used by your module your code returns as soon as possible.

From RISC OS 4, the kernel will look for a table of service numbers that the module wants to listen to, which avoids it sending unused ones to the module. It is strongly recommended that this is provided; future versions of RISC OS may even refuse to load modules without it.

This example code shows the recommended way to handle services.
Service entry
     EQUD     ServiceTable          ; offset of the service table
.ServiceCode
     MOV     r0,r0               ; a magic word
     TEQ     r1,#Service_One
     TEQNE     r1,#Service_Two
     TEQNE     r1,#Service_Three
     MOVNE     pc,r14
.ServiceDispatch
     STMFD     r13!,{r0-r3,r14}
     TEQ     r1,#Service_Two
     BEQ     Service_Two_Handler
     TEQ     r1,#Service_Three
     BEQ     Service_Three_Handler
.Service_One_Handler
     ...
     LDMFD     r13!,{r0-r3,pc}

.ServiceTable
     EQUD     0               ; flag word, currently zero
     EQUD     ServiceDispatch          ; offset of service dispatch code
     EQUD     Service_One
     EQUD     Service_Two
     EQUD     Service_Three
     EQUD     0               ; terminator

The service call numbers must be in ascending order.

[sh-index] Back to list of manuals