放入main()时内联汇编无法正常工作

时间:2015-12-11 08:27:03

标签: c assembly arm inline-assembly eabi

当我在main()中放入以下内联汇编时,它会在printf("before\n")之后直接停止。显然,由于未打印printf("after\n"),因此内联汇编块存在问题。当置于自己的函数run()中并使用main()mainssv();内调用时,相同的内联汇编运行完美。这个街区出了什么问题?

int main()
{
    while(1)
    {
        printf("before\n");

        asm volatile(
        ".syntax unified\n"
        ".text\n"
        ".arch armv7-a\n"
        ".fpu neon\n"
        ".thumb\n"
        ".global mainssv\n"
        ".func mainssv\n"
        ".thumb_func\n"
        "mainssv:\n"
        "        mov         lr, pc\n"
        "        adds        lr, lr, #63\n"
        "        bic         lr, lr, #63\n"
        "        mov         ip, 16\n"
        "    .p2align 2\n"
        "0:\n"
        "    .rept 130\n"
        "        vld2.8      {q0}, [lr, :128], ip\n"
        "        vaba.u8     q4, q4, q3\n"
        "        bne         1f\n"
        "1:      vld2.8      {q1}, [lr, :128], ip\n"
        "        vaba.u8     q5, q5, q0\n"
        "        vld2.8      {q2}, [lr, :128], ip\n"
        "        vaba.u8     q6, q6, q1\n"
        "        bne         1f\n"
        "1:      vld2.8      {q3}, [lr, :128], ip\n"
        "        vaba.u8     q7, q7, q2\n"
        "        smuad       r0, r1, r2\n"
        "        subs        lr, lr, #64\n"
        "    .endr\n"
        "        bne         0b\n"
        ".endfunc"
        );

        printf("after\n");
        }
}

0 个答案:

没有答案