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
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.
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.