Is it possible to refer a C variable inside inline asm? for example,
{
char abc;
#pragma asm
MOV A, abc;
#pragma endasm
}
after compile, I got a error at "MOV A, abc"
variable abc is not recognized by Compiler. I know I can do this in C, I just wonder if there is a way to use variable in inline assembly.
Thank you
Read-Only
Author erik malund
Posted 17-Aug-2005 23:18 GMT
Toolset C51
RE: in-line assembly use variable
erik malund
you can, the question is can you refer an overlaid variable? Thai I do not know (see below)
I do not use the ugly #pragma asm which require SRC and thus oblitterates the C code for the ICE; However if you rewrite the entire routine in assembler (recommended) in a separate module, you can use the OVERLAYABLE keyword for the local variables and THEN local variables are assembler accessible.
Read-Only
Author Hans-Bernhard Broeker
Posted 18-Aug-2005 13:52 GMT
Toolset C51
RE: in-line assembly use variable
Hans-Bernhard Broeker
Is it possible to refer a C variable inside inline asm?
Almost certainly not. The way C51 implements variables (allocating them into registers, overlaying locals from different functions, etc.) makes it pretty much impossible for the assembler to know where the variable will actually be, at a given point in the program.
The basic problem is that the interconnection between C51 and Ax51 isn't strong enough to support such tricks, due to the fact that C51 is designed to produce object files directly, rather than via assembly source.
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.