ARM System Calls: Difference between revisions

no edit summary
[unchecked revision][unchecked revision]
No edit summary
No edit summary
Line 38:
void __attribute__ ((interrupt ("SWI"))) swi_handler (int r0, int r1, int r2, int r3) {}
</source>
You have've probably noticed from the first examplethat (<span style="font-family:monospace">swi 0x420000</span>), that swi takes an integer as an argument. For it to work in both ARM and THUMB modes of the processor, the integer must be left shifted by 16. To get this integerargument in the C code, we have to do this:
<source lang="c">
uint8_t int_vector = 0;
asm volatile ("ldrb %0, [lr, #-2]" : "=r" (int_vector));
</source>
This loads the high 8 bits (16-23) of the argument into <span style="font-family:monospace">int_vector</span>, as loading the full 24-bits won't work using Thumb.
[[Category:ARM]]
[[Category:In Progress]]
Anonymous user