how to import #define to inline assembly

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

how to import #define to inline assembly

674件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by vinnt on Tue Nov 27 18:42:26 MST 2012
Hi,
    I have a question of how to import the #define in H file to inline assembly.

Original code:
    __asm("    ldr     r0, =_bss\n"
          "    ldr     r1, =_ebss\n"
          "    mov     r2, #0\n"
          "    .thumb_func\n"
          "zero_loop:\n"
          "        cmp     r0, r1\n"
          "        it      lt\n"
          "        strlt   r2, [r0], #4\n"
          "        blt     zero_loop");

Want to reduce the end address of zero_loop but _ebss should not be changed:
    __asm("    ldr     r0, =_bss\n"
          "    ldr     r1, =_ebss - SKIP_SIZE\n"
                    //SKIP_SIZE is a #define in H file
          "    mov     r2, #0\n"
          "    .thumb_func\n"
          "zero_loop:\n"
          "        cmp     r0, r1\n"
          "        it      lt\n"
          "        strlt   r2, [r0], #4\n"
          "        blt     zero_loop");

Does anyone know how to do this ? Much appreciate in advance.
0 件の賞賛
返信
1 返信

647件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Wed Nov 28 08:38:11 MST 2012
You can use #define macros in inline assembler, buy you cannot subtract from _ebss as you are trying to do, as _ebss is a symbol defined by the linker. If you insist in doing this, then you will need another instruction to subtract SKIP_SIZE from r1 after you have loaded.

It would be better if you could explain what you are trying to do, and why. There is probably a better way of doing it (and not zeroing bss is a dangerous thing to do)
0 件の賞賛
返信