To use a "local" in inline assembly, use func_name@local_name:
asm("mov A,[func_name@local_name]");
Here is an example of using HiTech C Inline Assembly for the PSoC showing local variables used in inline assembly:
- Code: Select all
unsigned short get_crc(unsigned char count,unsigned char *ptr)
{
unsigned short
crc; //Calculated CRC
unsigned char
i; //Loop count, bits in byte
unsigned char
data; //Current byte being shifted
crc=0xFFFF; // Preset to all 1's, prevent loss of leading zeros
do
{
data = *ptr++;
i=8;
do
{
if(((unsigned char)crc ^ data)&0x01)
{
//crc = crc >> 1 ^ POLY;
asm("and f, 0xFB"); //CLC
asm("rrc [get_crc@crc]"); //MSB
asm("rrc [get_crc@crc+1]"); //LSB
asm("xor [get_crc@crc],0x84"); //MSB
asm("xor [get_crc@crc+1],0x08"); //LSB
}
else
crc >>= 1;
data >>= 1;
}while(--i);
}while(--count);
return (~crc);
}

