How to access global variables of C into Assembly

Hi Forum Members,
I am using Keil uVision2 for P89C51RD2HBP.
I want to access the "global variables defined in C" in assembly routine. The format of my program is as below:

#include <stdio.h>

unsigned char Var1;

void Func1 (void)
{
...
...
#pragma asm
  mov  a,Var1
#pragma endasm
...
...
}
When I compile this program it says
"error A45: UNDEFINED SYMBOL (PASS-2)"

How do I solve this problem ?

Thanking you in advance,
Mr. Kiran V. Sutar

Parents
  • Hi Forum Members,
    I also would like to know how to deal with a similar problem in the following code :


    /* The Model used is Large */
    #include <stdio.h>
    
    unsigned char Var1;
    
    void Func1 (void) interrupt 1 using 2
    {
    ...
    ...
    #pragma asm
      mov  a,Var1
    #pragma endasm
    ...
    ...
    }
    
    
    Thanks again.

    Kiran V. Sutar

Reply
  • Hi Forum Members,
    I also would like to know how to deal with a similar problem in the following code :


    /* The Model used is Large */
    #include <stdio.h>
    
    unsigned char Var1;
    
    void Func1 (void) interrupt 1 using 2
    {
    ...
    ...
    #pragma asm
      mov  a,Var1
    #pragma endasm
    ...
    ...
    }
    
    
    Thanks again.

    Kiran V. Sutar

Children
More questions in this forum