Hello ZhaiHui,
The simplest way is to build the C-Function, then compile to assembler and copy the generated code into main assembler code. The advantage of this attempt is very simple procedure and you don’t need to save all possible affected registers used by compiled C-Function if it will be called from the asm code.
The next more complicated attempt is to define such exact position of the C-Function in *.prm file. Then if you want use this function you can use the “ld C_Addr” and “jmp ….” Command, but before you must save contents of all registers which could be used by compiled C-Function. In case you change this function you need to investigate which registers will be used by new C-Function and save possible other registers in asm code before use this function.
The other topic is the return from C-Function – you need to have saved the return address and use it when C-Function finishes.
So finally I suggest you to use the first option – write C-Function, compile it and copy the code into main asm code. It is more fluent asm code, more reliable and you don’t need pay attention to save the contents of many registers used by called C-Function.
I hope it can help you to solve your task.
Best Regards,
Stano.