Hello community!
I want to create some inline assembly examples for PowerPC architecture.
During the implementation I encountered several challenges.
For Example:
Function that sum two local variables and return the sum value.
While debugging the code I found out the code save the correct sum value in r0 register, but before it return value, I saw the r3 override with 0 value.
int my_asm_add_local(void)
{
int sum = 0;
int a = 4, b = 2;
asm volatile("se_add %1, %2\n\t"
"se_stw %1, 0(%0)\n\t"
: "=r" (sum)
: "r" (a), "r" (b)
);
return sum;
}
code from debugger
int my_asm_add_local(void)
182106F0 my_asm_a.:e_stwu r1,-0x10(r1) ; r1,-16(r1)
0080 se_mflr r0
D501 se_stw r0,0x14(r1) ; a,20(r1)
{
int sum = 0;
int a = 4, b = 2;
4840 se_li r0,0x4 ; a,4
4823 se_li r3,0x2 ; r3,2
asm volatile("se_add %1, %2\n\t"
0430 se_add r0,r3 ; a,b
D003 se_stw r0,0x0(r3) ; a,0(r3)
"se_stw %1, 0(%0)\n\t"
: "=r" (sum)
: "r" (a), "r" (b)
);
return sum;
4803 se_li r3,0x0 ; b,0
}
C501 se_lwz r0,0x14(r1) ; a,20(r1)
0090 se_mtlr r0
20F1 se_addi r1,0x10 ; r1,16
0004 se_blr
4444 se_or r4,r4
I would appreciate any help.
In addition, if anyone knows a good source information with examples of inline assembly for PowerPC, it is could be help.
Please disassemble the library code provided in CodeWarrior project to generate assembly code.