Inline assembly in function definition to add two values passing to the function as arguments
Would appreciate if someone can tell/show me how to create a variable in assembly. I'm having a small assignment that I have to pass two values to a function as arguments & in function definition I need to add the two values and the sum is to be return to the main function. The addition in function definition need to write in inline assembly. Is this possible that can we return the value or variable from the assembly? How to create a variable in assembly & how to assign the value to it? I know that how to write inline assembly in keil C and generate its SRC. As I'm a learner of assembly & keil C waiting for helpful messages from u eagerly. Thank U.
Why do you "need" to do this in inline assembly?
Presumably, this is purely a (school) exercise - as C51 is perfectly capable of adding 2 numbers without using inline assembler!
Before proceeding, please see this thread and read the linked article: http://www.keil.com/forum/docs/thread17856.asp
It is almost always better to create a separate assembler function than to mess about with inline assembler - especially with the way that C51 handles inline assembler!
For an example of how to easily create a 'C'-callable assembler function, see: www.8052.com/.../149030
You will also need to be familiar with: http://www.keil.com/support/man/docs/c51/c51_ap_segname.htm And: http://www.keil.com/support/man/docs/c51/c51_ap_ctoasm.htm And: http://www.keil.com/support/man/docs/c51/c51_ap_datastorage.htm
And don't forget the Knowledgebase links in the C51 Manual page on inline assembler: http://www.keil.com/support/man/docs/c51/c51_asm.htm