We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Dear Sirs,
I want to write a function likes below,
int sub(unsigned int x)
{
#pragma ASM
MOV A,#x
#pragma ENDASM
}
But the keil-C shows the message: error A45: UNDEFINED SYMBOL (PASS-2)
Does the Assembler not know how to access the variable in C ?
How could I pass the variable from C to assemble?
Really thanks for your reply.
BR,
Eddie
Some related Keil- and Arm-docu to refer to:
- "C51: MIXING C AND ASSEMBLY" : http://www.keil.com/support/docs/1671.htm
- Embedded assembler syntax in C and C++" : http://www.keil.com/support/man/docs/armcc/armcc_chr1359124253861.htm
- "Inline assembly language syntax with the __asm keyword in C and C++": http://www.keil.com/support/man/docs/armcc/armcc_chr1359124246903.htm
- "Writing inline assembly code": http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.100748_0606_00_en/lmi1470147220260.html
shihwen chou said: I want to write a function likes below
Why?
If it really needs to be done in assembler, then do it in a proper assembler module.
For an easy way to create a 'C'-callable assembler function, see:
http://www.8052mcu.com/forum/read/149030
I wholeheartedly support using that approach, inline assembler usually end up in something unmaintainable.
in my book "difficult to maintain" equals unmaintainable