i have a c function for eg : void function_name(char param1,char param2)
now i want to call this function from assembly code.
i know that how to call a c funtion with one parameter from assembly
eg: ldab #12
jsr function_name
but i dont know how to pass two parameters from assembly while calling a c function.
i am using microcontroller MC9S12XDT512
and i am using freescale code warrior.
so please suggest if any body know how to do it.
Solved! Go to Solution.
void function_name(char param1,char param2);
try this
LDAB <param1_value>
PSHB
LDAB <param2_value>
JSR function_name ; (JSR or CALL depends on memory model)
LEAS 1,SP ; remove param1 from stack
Hello
If you wish to call a function implemented in assembler from an ANSI C function, you need to match the C compiler calling convention in your assembler function.
If you are using the CodeWarrior compiler, the calling convention and parameter passing scheme is described in the file Compiler_HC12.pdf, chapter Using the Compiler, section HC(S)12 Backend > Call Protocol and Calling Conventions.
I hope this helps.
CrasyCat
thanks crasy for the reply
i looked into the pdf you mentioned above and yes there is topic about Call Protocol and Calling Conventions. but i m still not able to apply it .
if possible could you provide me some examples of calling a c function from assembly which has two parameters or more.
thanks
void function_name(char param1,char param2);
try this
LDAB <param1_value>
PSHB
LDAB <param2_value>
JSR function_name ; (JSR or CALL depends on memory model)
LEAS 1,SP ; remove param1 from stack
Hi Edward .
i tried it and its working fine.
thanks for the help thanks a lot