Note that there are some explanatory texts on larger screens.

plurals
  1. POWriting own SVC calls ARM assembly
    primarykey
    data
    text
    <p>I would like to know the proper way of writing SVC calls on an ARM-based microcontroller.</p> <p>My understanding so far is that ARM has an exception vector table, meaning that the first instructions in any program have to be branches to the appropriate handlers:</p> <pre><code>RESET ;Handles reset UNDEFINED ;Undefined instructions SVC BL SVC_Entry PRE_ABORT ;Prefetch abort DAT_ABORT ;Data abort </code></pre> <p>Then, every time an SVC instruction is ran, the mode is switched to supervisor, the number provided with the SVC is stored in R0 and the program would branch to an appropriate handler:</p> <pre><code>;== Handling SVC calls ======================================================== Max_SVC EQU 1 SVC_Entry CMP R0, #Max_SVC ;Check upper limit BHI SVC_end ;Does nothing if unknown ADD R0, PC, R0, LSL #2 ;Calculate table address LDR PC, [R0, #0] Jump_table DEFW SVC_0 ;Halt DEFW SVC_1 ;Print string ;== SVC calls ================================================================ SVC_1 B SVC_end SVC_end MOVS PC, LR ;Exiting </code></pre> <p>So, if we have these instructions:</p> <pre><code>ADR R1, string ;R1 points to the string SVC 1 ;SVC_1 handles the printing </code></pre> <p>The program would have to switch to supervisor mode, have the number "1" stored in R0, and following the jump table branch to SVC_1, run the code and switch back to user mode.</p> <p>Is this correct? Am I doing it right?</p> <p>The problems I have so far is that my compiler says "operator expected" for this line:</p> <pre><code>SVC BL SVC_Entry </code></pre> <p>Information on this topic is hard to find on the internet and I just want to know how to properly use SVC calls on an ARM microcontroller.</p> <p>Thank you very much.</p> <p><strong>EDIT:</strong> The underlying processor is an ARM9 clocking at around 240 MHz. This lives in an AT91 microcontroller. The lab board on which it resides has been modified to fit my University's needs.</p> <p>The code is loaded on the board using a custom-made program through a serial port. The program also allows debugging.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload