Hi,
Im using the STM32F103ZE uC.
I wrote an assembler function calling it from C (vS00StmJmp(x)) with one argument representing an index in a jumptable. The assembler function then jumps to the selected C-function.
;------------------------------------------------------------ vS00StmJmp ; push r3 ; save used register r3 on stack adr r3, JumpTable000 ; store jump-table start address in register r3 cmp r0, #nLstJmpNum ; check requested jump table entry number ble lblRunJmp ; on valid number then jump to table jump execution mov r0, #0 ; on invalid number, select table record #0 lblRunJmp ; destination label LDR pc, [r3,r0,LSL#2] ; jump to address in r3 with offset in r0 with offset-size 4 (LSR#2) ;------------------------------------------------------------
As one argument is used which is automaticaly tranferred by register R0 I assume the compiler will take care of the correct handling of this register. But the assembler function uses register R3 so I asume I must prepair to return the previous value back into R3 when exiting from the jump. But how can I achieve this as a jump is executed to the selected C-function. Should I somehow execute an assembler function after executing vS00StmJmp(x) which pops R3 back from stack (after having in pushed on stack in the first line of my assembler code?)
Just let me know...Thanks
Henk