Hi,
I am trying to migrate my project to ARM compiler 6.19 from an older version (5.xx).
In Compiler 5.xx, I know that the asm instruction "PRESERVE8" is used to specify that the current file preserves the eight-byte alignment of the stack.
This instruction is causing a linker error and I couldn't find any translation in the document "Migrate ARM Compiler 5 to ARM Compiler 6" or any other online forum.
How do I rewrite this instruction compatible with ARM Compiler 6? Is there any documentation available that describes how to resolve this issue?
Any help is much appreciated. Thank you
Hello,
The equivalent directive is:
.eabi_attribute Tag_ABI_align_preserved, 1
See the end of the table here, and the notes on its use:https://developer.arm.com/documentation/100068/0620/Migrating-from-armasm-to-the-armclang-Integrated-Assembler/Miscellaneous-directives
Hello Ronan,
Thank you for this information, but where exactly I need to put this line? I tried to put it into the
Best regards, Iknerf
This is only for true assembler source files.
Using the inline assembler in C source behaves differently. For example, the __attribute__((naked)) source only supports the most basic assembler.
Ronan
How can I then specify 8 byte alignment in embedded assembly in C? The PRESERVE8 does not work as I get error unexpected token in argument list?
Thanks for the answer, Iknerf
I _think_ if you wrap it in a standard C function, this should be implied.
Well I did, but I get error as I already mention before:: error: use of undeclared identifier 'PRESERVE8'
: error: use of undeclared identifier 'PRESERVE8'
The code is like that:
void test(void)
{
PRESERVE8;
__asm(
"THUMB"
"PUSH {r0-r3,lr}"
...
It would be something like:
void test(void) { __asm{ "PUSH {r0-r3,lr}" } ...
See developer.arm.com/.../Inline-assembly-with-Arm-Compiler-for-Embedded-6
Are you sure I need to use curly brackets?
From the compiler user manual and reference manual. I also checked the link you provided and after the __asm I need to use normal brackets ().
And I dont see where you put the PRESERVE8 ? Also THUMB is not recognized.
Best regards, Frenk
Apologies for the bracketing typo.
You would not specify PRESERVE8 (or THUMB). Again, the inline/embedded assembler is not the same as the 'full' assembler.
Ok, I understand.
So for inline assembly I dont need to specify this 2 statements as armclang will use them automatically OR do I need to specify any specific flag for this? I know armclang has -mthumb (which is set but also set by default) and in the armlink I can specify 8 byte alignment. But do I need to specify anything else?
I am porting from the very old code and there is everything written :-), so now I have to figure out how to port it to new armclang and this is a working example (check how to call C function and that at end of each line you need \n\t otherwise build fails):
void test(void){ __asm{ "PUSH {r0-r3,lr}\n\t"
__asm{
"PUSH {r0-r3,lr}\n\t"
"BL testC\n\t"
I don't think there is any special flag needed.
Compiling for Cortex-M implies Thumb code (they do not have the concept of Arm and Thumb state).
I appreciate that porting such code can be a non-trivial task.