Module Header
Adolf Brady (2580) 5 posts |
Hi all! 1º When it comes to ‘Start Code’ it says it’s mostly outdated. Could you show me an example where it’s used? |
Jon Abbott (1421) 2608 posts |
It’s not outdated or deprecated and is still used. A filer module is one example (the filesystem icons down the bottom left.)
This should be avoided, it may have even been deprecated as it will break the OS if CLib is softloaded and then relocated by RMTidy.
Yes, you have to load the module that provides the SWI before you can use it.
No, the &40000 range is reserved for OS extensions. The user range is &C0000 off the top of my head. You’re advised to request an SWI block allocation if you plan to make something public.
The OS will advertise Service Calls to modules before/after it performs certain actions. They’re useful if you need to do things after a MODE change or when memory is relocated for example. Service calls are unrelated to SWI’s. |
Jeffrey Lee (213) 6046 posts |
When it comes to ‘Start Code’ it says it’s mostly outdated. Could you show me an example where it’s used? Another example would be BASIC, where the *BASIC command calls OS_Module 0 so that BASIC can start itself as a task/program. Is RMTidy outdated too? Yeah, I’d say avoid using *RMTidy. I’m not 100% sure when it was changed (RISC OS 3.5? Whenever FSLock was introduced), but on all modern OS versions it does nothing. And on the machines where it does work, I’d say it should be the user’s choice whether it should be used, not the programmer’s. |
Adolf Brady (2580) 5 posts |
Thank you for your responses :) Jeffrey, I thought that kind of commands were created in the ‘Help and command keyword table’ of a Module. I don’t see the difference between SWI and Service Calls, can they be called globally? I see both of them are passed parameters via registers. In relation to ‘OS_Module11’, R1 is a pointer to the Module. How I get the memory address of a Module that I’ve just created? |
Martin Avison (27) 1428 posts |
Yes, but not ‘every time’ … the SWI will then be available until an ‘*RMKill X’ (or a reboot!). |
Rick Murray (539) 13422 posts |
A difference is that you can use the Start entry to start a module as an application (in user mode). Normal modules provide “services” (the *Commands and all those SWIs) but you can also have a module provide an application. It doesn’t tend to get used much by programmers, but some stuff requires it to start in a certain way – the Filer for example, as has been pointed out. It runs as a module (gives various services to the OS) and it also runs as a Wimp application (so you have icons to click on).
Commands used in the command line, affectionately known as “star commands” are indeed defined in the Help and command keyword table. However, as has been pointed out, BASIC provides a command ( To demonstrate this…
Run it, it will build a tiny program called “RunBASIC”. Run that, and BASIC will appear. It doesn’t call *BASIC, it asks the OS to look up the module called “BASIC” and enter it via its Start entry.
A SWI is a command to a specific module. For example, A Service Call, by contrast, is something (often the OS) handing around a notification that some specific event has occurred. For example Service Call &46 is passed around to all modules to notify them that the screen mode has changed, so any module that maintains information on the screen (FontManager, for instance) should reread the screen layout (resolution, eigen, colours…). While a Service Call can be claimed, most are for notification and are not claimed, hence will be passed around to every module (a module can specify what it is interested in, to save wasting time and resources). In general, a SWI is a request for something to be done and a Service Call is a notification of some specific event having happened. Please refer to PRM 1-256 (Service Calls).
…that’s normal. Actually, usually the Service Call passes you parameters in registers.
Generally, you don’t need to. Once a module has been linked into the system, you communicate with it using star commands, and SWIs, etc; as well as the OS’s own module handling ( If you really need the address of the module (and you shouldn’t), you can retrieve it using OS_Module 18:
The “num%” is the module number (in case you need it for other calls) and “base%” is the address of the start of the module code in the RMA. |