This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How can I accessing a variable in Assembler Code ?

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;

}

#pragma asm

MOV A,Var_C /* This line is not work */

MOVX @DPTR,A

INC DPTR

#pragma endasm

}

}

Build target 'Target 1'

compiling main.c...

main.src(181): error A45: UNDEFINED SYMBOL (PASS-2)

Thanks!!!

Parents
  • If you just use assembly code just after the return from a function,then the return value resides in the register bank which the called function using(If you don't know the accuracy location,see C51.pdf).For the Keil compiler uses register banks to transfer parameters and return values.

    In your case,searching the .SRC file generated form the .C file will lead you to the right place.

Reply
  • If you just use assembly code just after the return from a function,then the return value resides in the register bank which the called function using(If you don't know the accuracy location,see C51.pdf).For the Keil compiler uses register banks to transfer parameters and return values.

    In your case,searching the .SRC file generated form the .C file will lead you to the right place.

Children