This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARMCompiler6.18 armasm inline assembly syntax

I tried to switch my compiler from ARM V5 to V6, and I faced a inline assembly funciton conversion issue:

[Original]

DATA_RAM_FUNCTION __asm void prvEnableVFP_RTT(void)
{
    PRESERVE8
    
    /* The FPU enable bits are in the CPACR. */
    ldr.w r0, = 0xE000ED88
    ldr r1, [r0]
    
    /* Enable CP10 and CP11 coprocessors, then save back. */
    // orr r1, r1, #( 0xf << 20 )
    orr r1, r1, #0xf00000
    str r1, [r0]
    bx r14
    nop
}

[After Conversion]

DATA_RAM_FUNCTION void prvEnableVFP_RTT(void)
{
    __asm volatile(
    ".eabi_attribute Tag_ABI_align_preserved, 1 \n"
    "ldr.w r0, = %0 \n"
    "ldr r1, [r0] \n"
    "orr r1, r1, #0xf00000 \n"
    "str r1, [r0] \n"
    "bx r14 \n"
    "nop \n"
    : /* no outputs */ : "r"(0xE000ED88) : "r0", "r1", "r14"
    );
}

There is a error:

./.rtt-studio/Debug\rtthread.axf: Error: L6218E: Undefined symbol r2 (referred from lto-llvm-293411.o).

What's going wrong?

Parents Reply Children
  • After converting, I could compile with AC6 but some bugs existed.

    I have checked out the Disassembly window in Keil MDK v5.37:

    [result in my original AC5 project]

    0x00208400 F8DF000C  LDR.W         r0,[pc,#12]  ; @0x00208410
    0x00208404 6801      LDR           r1,[r0,#0x00]
    0x00208406 F4410170  ORR           r1,r1,#0xF00000
    0x0020840A 6001      STR           r1,[r0,#0x00]
    0x0020840C 4770      BX            lr
    0x0020840E BF00      NOP           

    [result in AC6 converted compilable project]

    0x0020844E F8DF02DC  LDR.W         r0,[pc,#732]  ; @0x0020872E
    0x00208452 6801      LDR           r1,[r0,#0x00]
    0x00208454 F4410170  ORR           r1,r1,#0xF00000
    0x00208458 6001      STR           r1,[r0,#0x00]
    0x0020845A 4770      BX            lr
    0x0020845C BF00      NOP           

    There is a different part at the first line between the two results, it lead to the different address for getting data between AC5 and AC6 project.

  • I tried to change this value, but the correspond #value will not change(stay #732).

  • On what basis did you form the assumption that these operands would have to be the same for that code to work?

  • Actually I have no basis, and it seem that these operands are impossible to be the same. You gave me another train of thought.

  • After I fixed syntax errors, there is the newest compilable inline assembly function, and my project stuck here.

    DATA_RAM_FUNCTION void prvEnableVFP_RTT(void)
    {
    	__ASM volatile(
    		".eabi_attribute Tag_ABI_align_preserved, 1 \n\t"
    		"ldr.w r0, = 0xE000ED88                     \n\t"
    		"ldr r1, [r0]                               \n\t"
    		"orr r1, r1, #0xf00000                      \n\t"
    		"str r1, [r0]                               \n\t"
    		"bx  r14                                    \n\t"
    		"nop                                        \n\t"
    		: : : "r0", "r1", "r14", "memory"
    	);
    }

  • I just set multi print function in my inline funciton to check where the bug was

    DATA_RAM_FUNCTION void prvEnableVFP_RTT(void)
    {
    	rt_kprintf("function entry \n");
    	__ASM volatile(".eabi_attribute Tag_ABI_align_preserved, 1 \n\t");
    	rt_kprintf("function point(1) \n");
    	__ASM volatile("ldr.w r0, = 0xE000ED88                     \n\t");
    	rt_kprintf("function point(2) \n");
    	__ASM volatile("ldr r1, [r0]                               \n\t");
    	rt_kprintf("function point(3) \n");
    	__ASM volatile("orr r1, r1, #0xf00000                      \n\t");
    	rt_kprintf("function point(4) \n");
    	__ASM volatile("str r1, [r0]                               \n\t");
    	rt_kprintf("function point(5) \n");
    	__ASM volatile("bx  r14                                    \n\t");
    	rt_kprintf("function point(6) \n");
    	__NOP();
    	rt_kprintf("function end \n");
    }

  • It seems here is the break point

    __ASM volatile("bx  r14  \n\t");

  • And fnially I found that project is past project, so some image in flash are not compatible(in the correct memory address) with defined address in code.