I use #pragma asm/#pragma endasm to embed Assembler Code in C Function.
My question is:
How can I accessing a variable in Assembler Code,which define by C code.
Just like this:
I need height speed to accessing XDATA from Addr 0x0000.
void Func() {
unsigned char Var_C,i=0;
#pragma asm
mov DPTR,#0x0000
#pragma endasm
while(i++ < 0x10)
{
Var_C = ReadOneByte();
if(Var_C == 0xff)
Var_C = 0;
}
MOV A,Var_C /* This line is not work */
MOVX @DPTR,A
INC DPTR
Build target 'Target 1'
compiling main.c...
main.src(181): error A45: UNDEFINED SYMBOL (PASS-2)
Thanks!!!
"In your case, searching the .SRC file generated form the .C file will lead you to the right place."
Also, reading the section in the Manual titled "Interfacing C to Assembler".
The clue is in the name!
http://www.keil.com/support/man/docs/c51/c51_ap_ctoasm.htm
"I need height speed to accessing XDATA from Addr 0x0000."
It's hard to see what your code is actually doing, because you didn't follow the instructions when posting it - see above.
Anyhow, it seems very unlikely that you are going to gain any advantage by simply throwing odd bits of inline assembler into your 'C' source.
For a start, if speed is what you need, then a function call is not the way to read a single byte!
Have you read "Writing Optimum Code" in the Manual?
http://www.keil.com/support/man/docs/c51/c51_xc.htm
Have you enabled optimisation & examined the code that the compiler generates? It could well be pretty good anyhow!
If not, you probably need to write the whole function in assembler.
"main.src(181): error A45: UNDEFINED SYMBOL (PASS-2)"
Which symbol is it saying is undefined?