Hi,
I have some assembly routines located in ROM memory, for example asmfunc that is located at address 0xF700 - is absolute address of flash memory.
The program memory is organized: ROM code from address 0xF000 - 0xFFFF Flash code from address 0x0000 - 0xEFFF
I have my C code and I want to call from C the assembly function asmfunc located at address 0xF700, how I can do this?
I know to call function asmfunc if my code is in Assembly using for example this:
asmfunc equ 0xF700 . . lcall asmfunc . .
Thanks, Nels
The C convention is that function names start with an underscore. So, name your asm functions accordingly, and export the names of the functions with "public".
Asm.a51
PUBLIC _AsmFunc _AsmFunc: RET
Asm.h
extern void AsmFunc (void);
C.c
void main (void) { AsmFunc(); }
If you're trying to jump to a particular address that you maintain manually, rather than letting the linker do it for you as above, then you can do something like: #define AsmFuncAddr 0xF700 *(AsmFuncAddr)(); to cast the integer constant to a function pointer and call the function. Generally if you go this route, it's a good idea to have vector table so that there's only one hardcoded address.
"The C convention is that function names start with an underscore."
C51 also has other conventions - you must read the Manual...
First of all I read the manual. I think the problem is not "underscore" in assembly function but:
My flash memory is mapped 0x0000-0xF000 for flash code, 0xF000-0xFFFF this address is re-mapped to other memory - ROM memory, here I have assembly code with some routines.
so in my case I have two firmware projects! one project_rom.Uv2 written in assembly located in ROM, other project_flash.Uv2 located in the flash.
I would like to call directly some assembly routines located in ROM from "C" in the flash memory --> that corresponds to the project_flash.Uv2
Thanks you.