I am writing an application in which I need to mix C and assembly. I need to write the most optimized code for which I need the answer to the following questions 1) When passing parameters, is there any predetermined method in which the parameters will be passed? Like for eg. param1 will be passed thorugh r6, parameter 2 will be assed thorugh r7 etc? 2) When returning from a function is there any standard fixed way of returning like , say the return value is always in register r7 ?
If these things are predetermined then I can do a lot of speed optimizations in my code
Will appreciate if you could help.
Thank you. Regards Gaurav
HELLO PLEASE
I NEED TO PRINT NUMEBR IN BCD WITH PRINTF
BUT MANUAL DOES NOT GIVE EXAMPLE
HOW TO DO?
THANK YOU
To add to the list of questions I am not able to find the link between registers and C variables when mixing C and assembly. For example if I want to mov the value in a register to a variable and say I have declared the variable like void func() { char c; #pragma asm call assemblyfunc ;Now I want to move the value in register r7 to the ;variable c ;I wud do mov variable_c_allocation_name, r7 }
Now the question is what will be variable_c_allocation_name?
Is there any standard naming convetion that keil compiler uses. I see that variable c would be named something like c?040 or or c?141 etc. What does the numbers 0, 4, 0, stand for?
Regards, Gaurav
There is a section in the manual titled "Interfacing C to Assembler" - it will answer your questions!
http://www.keil.com/support/man/docs/c51/c51_ap_ctoasm.htm