We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hallo
Im just wondering what the advantage is of using software interrupt instead og a function call?
Is the SWI faster? Cant it be disturbed by another interrupt?
/Thomas
A SWI can be interrupted by a FIQ unless these are shutdown manually, but not by an IRQ. Invoking a SWI involved some overhead (see your startup code) - unless you really need it, consider calling a function and disabling interrupts around data that needs to be guarded.
Ok, I see.. But the problem is that I cant see what I need SWI for? :-) The only use is then to "protect" data for beeing altered by a IRQ?
Thomas
when you execute a SWI instruction, the processor enters SVC mode which is privileged - which gives you access to changing CPSR.
If I am not mistaken, SWI is used to switch the CPU from user to supervisor mode. It often makes sense to run the whole program in supervisor mode, in which case SWI is useless.
One use for SWI instructions is for compiler implementors. In the Armaide Oberon-07 Development system, runtime errors generate SWI instructions. e.g. array indices are checked against array bounds. If the element being accessed is out of range an SWI instruction is generated to call a trap routine which can then return to a suitable recovery point that you have defined in your program.
All you need to do is add the following procedure call at the location in your application that you want to return to:
LPC.SetTrapReturn(SYSTEM.FP, SYSTEM.SP, SYSTEM.PC + 0);