|ARM Technical Support Knowledge Articles|
Applies to: A51 Macro Assembler
Information in this article applies to:
I have a hybrid program that is half in assembly and half in C. All my global variables are declared in assembly. I access these variables from my C program. Everything compiles and links with no errors.
However, when I look at the C listing file, the compiler has generated code that accesses my variables as 2-byte objects even though the variables declared in the assembler are only 1 byte long. What causes this to happen and how can I fix it?
When you declare a variable in assembly that you will use in C, you must ensure that the memory area and data type match exactly. If the variable you declare in assembly is in XDATA memory and it is 1 byte long, the corresponding C data type must be declared as one of the following:
char xdata var; unsigned char xdata var;
The easiest way to verify that your assembly variable declarations are correct is to declare all global variables in C in a single source file and compile that C source file using the SRC directive for the compiler. The resulting .SRC file will contain the assembly code necessary to declare the variables. You may use the .SRC file to declare your C variables in assembly.
Article last edited on: 2006-08-18 08:41:57
Did you find this article helpful? Yes No
How can we improve this article?