我试图编译和例子唱霓虹灯装配代码为皮质A8使用这个二进制的BeagleBone黑板(BBB)。我使用eclipse工具GCC编译器和汇编程序,
GCC : arm-linux-gnueabi-gcc 汇编程序: arm-linux-gnueabi-as
下面的错误发生在一个示例中,对于我使用的每个示例,我都会发现类似的错误
Description Path Resource Location Type
SP not allowed in register list -- `ldmia r12,{r4-r11,r13,lr}' EXAMPLE_NEON line 61, external location: /tmp/ccTXrczs.s C/C++ Problem我用的代码
/************************
\* neon.c \* \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/#include <stdio.h>
__attribute__((aligned (16)))
unsigned short int data1[8];
unsigned short int data2[8];
unsigned short int out[8];
void* neontest_save_buffer[16];
void
neontest(unsigned short int *a, unsigned short int *b,
unsigned short int* q)
{
__asm__(
" movw r12, #:lower16:neontest_save_buffer\n\t"
" movt r12, #:upper16:neontest_save_buffer\n\t"
" stmia r12, {r4-r11, r13, lr} @ save registers\n\t"
" vld1.16 {q1}, [r0:128]\n\t"
" vld1.16 {q2}, [r1:128]\n\t"
" vadd.i16 q0, q1, q2\n\t"
" vst1.32 {q0}, [r2:128]\n\t"
" movw r12, #:lower16:neontest_save_buffer\n\t"
" movt r12, #:upper16:neontest_save_buffer\n\t"
" ldmia r12, {r4-r11, r13, lr} @ reload all registers and return\n\t"
"finish:\n\t"
);
}
int
main(void)
{
int i;
for (i=0; i<8; i++)
{
data1[i]=i*10;
data2[i]=5;
out[i]=0;
}
neontest(data1, data2, out);
printf("output is: ");
for (i=0; i<7; i++)
{
printf("%d, ", out[i]);
}
printf("%d\n", out[i]);
return(0);
}发布于 2015-02-21 12:35:57
看起来您使用的是Thumb32模式,在这种模式中,sp cannot be in the list of registers (来自[1])。
如果没有设置新堆栈,为什么需要保存堆栈?只需尝试从r13块和ldm块中删除ldm。
发布于 2016-10-05 21:22:00
默认情况下,编译器使用拇指模式,在命令行中添加"-marm“以ARM模式编译代码:
arm-linux-gnueabihf-gcc -mcpu=cortex a8 -mfpu=neon -marm nonn.c
您还可以调整代码,让编译器进行寄存器保存/还原,这样就可以为ARM和thumb2指令集编译代码:
#include <stdio.h>
__attribute__((aligned (16)))
unsigned short int data1[8];
unsigned short int data2[8];
unsigned short int out[8];
void
neontest(unsigned short int *a, unsigned short int *b,
unsigned short int* q)
{
__asm volatile (
" vld1.16 {q1}, [%[a]:128]\n\t"
" vld1.16 {q2}, [%[b]:128]\n\t"
" vadd.i16 q0, q1, q2\n\t"
" vst1.32 {q0}, [%[q]:128]\n\t"
: [q] "+r" (q)
: [a] "r" (a), [b] "r" (b)
: "q0", "q1", "q2"
);
}
int
main(void)
{
int i;
for (i=0; i<8; i++)
{
data1[i]=i*10;
data2[i]=5;
out[i]=0;
}
neontest(data1, data2, out);
printf("output is: ");
for (i=0; i<7; i++)
{
printf("%d, ", out[i]);
}
printf("%d\n", out[i]);
return(0);
}臂-linux-gnueabihf-gcc-mcpu=皮层-a8 -mfpu=neon -marm nonn2.c
臂-linux-gnueabihf-gcc-mcpu=皮层-a8 -mfpu=neon -mthumb nonn2.c
https://stackoverflow.com/questions/28645197
复制相似问题