Wednesday, September 17, 2014

Setting C variable from ASM

- in c code
unsigned int g_asm_var = 0xdead; //initialization seems mandatory??
EXPORT_SYMBOL(g_asm_var);

- in assem code
.global g_asm_var;



    stmdb sp!, {r11} //optional
    ldr    r11, =g_asm_var
    str    \ttbr1, [r11] // str r3, [r11]
    ldmia    sp!, {r11} //optional

     stmdb sp!, {r0 - r3}
    ldr    r0, =g_ttbr_smp
    ldr    r1, =g_ttbr_up
    mov    r2, #TTB_FLAGS_SMP
    mov    r3, #TTB_FLAGS_UP
    str    r2, [r0]
    str    r3, [r1]
    ldmia    sp!, {r0 - r3}

No comments:

Post a Comment