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.
Hello How can i instruct keil to use BLX instruction instead of BL.W while calling functions ?
any compiler settings ?
I need to call a function which is there in flash from ram code. Thanks.
Call it thru a function pointer.
; Reset handler Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT SystemInit IMPORT __main BL.W SystemInit ; Relative LDR R0, =SystemInit BLX R0 ; Anywhere in 4GB space LDR R0, =__main BX R0 ENDP
Reset_Handler 0x00000000: f7fffffe .... BL SystemInit 0x00000004: 4806 .H LDR r0,[pc,#24] ; [SystemInit = 0x20] = 0 0x00000006: 4780 .G BLX r0 0x00000008: 4806 .H LDR r0,[pc,#24] ; [__main = 0x24] = 0 0x0000000a: 4700 .G BX r0
Fixup the relative form based on the address you use, or use a PC relative form to load a literal into a register and use that. Use a jump table with absolute addresses.
Generally best to keep all the code you want in RAM so as not to touch FLASH. Or use an attribute/pragma to push the functions you want in RAM into a section your describe in RAM via the scatter file load region.