Keil Logo Arm Logo

Discussion Forum

in-line assembly use variable

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
wwwrabbit W
Posted
17-Aug-2005 22:49 GMT
Toolset
C51
New! in-line assembly use variable
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
New! RE: in-line assembly use variable
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
New! RE: in-line assembly use variable
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.

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Keil logo

Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.