Hello! How can i call function from asm file to the c file into one project using directive EXPORT? Thanks.
A metric or imperial shedload?
I just wish I could have found a good vulcan embedded engineer, sharing his knowledge would have been so much easier.
Unfortunately relying on others for knowledge tends to significantly reduce the value of potential hires. There has to be more material available these days, and it's far easier to search and locate.
Perhaps you could just look at the startup_stm32f0xx.s for inspiration?
That's the very thing I did many moons ago when I started this embedded career. If only the Keil forum were available back then, I could have saved a shedload of time and just asked here for the information.
Calling C functions
IMPORT SystemInit LDR R0, =SystemInit BLX R0
void SystemInit(void) { // .. }
Calling ASM functions
foo PROC EXPORT foo bx lr ENDP ; foo
extern void foo(void); foo();
That sounds complicated. If you want an assembler file to call a C function, it's a bit interesting why you want to use the keyword EXPORT. Don't you think that would be the reverse of what you need?
If the assembler is going to call a C function, you would need to import the C function name into the assembler file "name space". Export is if you want a symbol in the assembler file to be reachable from some other file, in which case the symbol name must exist in the object file so the linker can find and match the symbol later.
How to do that? In the same way that all the Keil assembler startup files does so the startup files can call helper functions in the CRTL and/or main().
View all questions in Keil forum