Access variables in a C program from inline asm

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Access variables in a C program from inline asm

1,676 次查看
rasmusnygaard
Contributor I
How do I access variables in a C program from inline asm. Now I access the variable by writing direct to the RAMadress from asm.
 
What do I write instead of XXX when I want to increment the testvar?
 
void main()
{
   char testvar;
 
   asm
   {
      inc XXX
   }
}
 
Best regards
Rasmus L. Nygaard, Denmark
标签 (1)
0 项奖励
2 回复数

376 次查看
rasmusnygaard
Contributor I
Thanks - it works. I did not even try this straight forward method, because of my experience from other compilers.
0 项奖励

376 次查看
CrasyCat
Specialist III

Hello

I assume you are using CodeWarriot for HC08. AM I right?

You just use the variable name as defined.

void foo(void)
{
   char testvar;
 
   __asm
   {
      inc  testvar
   }
}

CrasyCat

0 项奖励