ARM System Calls: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content deleted Content added
No edit summary |
No edit summary |
||
Line 38: | Line 38: | ||
void __attribute__ ((interrupt ("SWI"))) swi_handler (int r0, int r1, int r2, int r3) {} |
void __attribute__ ((interrupt ("SWI"))) swi_handler (int r0, int r1, int r2, int r3) {} |
||
</source> |
</source> |
||
You |
You've probably noticed that <span style="font-family:monospace">swi</span> takes an integer argument. To get this argument in C, we have to do this: |
||
<source lang="c"> |
<source lang="c"> |
||
uint8_t int_vector = 0; |
uint8_t int_vector = 0; |
||
asm volatile ("ldrb %0, [lr, #-2]" : "=r" (int_vector)); |
asm volatile ("ldrb %0, [lr, #-2]" : "=r" (int_vector)); |
||
</source> |
</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:ARM]] |
||
[[Category:In Progress]] |
[[Category:In Progress]] |