[Fwd: ARM GCC inline assembly]

Ganesh Tawde ganesh.tawde@patni.com
Sat Apr 24 07:52:00 GMT 2004


Hi.

I am trying to use the below pure assembly code as inline assembly in C.
The pure assembly code gives proper data but the inline assembly code
gives me distorted data. I am not able to figure out the problem. can any
body help me on this?

here is the working pure assembly function
*************************************************************************

	@AREA ARM , CODE ,READONLY
@;--------------------------------------------------------------
@	;dec2 assembly code called from res2_inv.c
@;--------------------------------------------------------------

	.global dec2

dec2:
        stmdb r13!, {r4-r12, lr}

	ldmia r3!,{r6,r7}

	mov r14,r7	@n
	mov r8,r6	@shift

	mov r3,r8

dec2loop:

	ldmgeda r2!, {r12}
	ldmgeia r12!, {r8, r9}
	ldmgeia r0, {r4, r5}
	ldmgeia r1, {r6, r7}
	add r4,r4,r8,  asr r3
	add r6,r6,r9,  asr r3

	ldmgeda r2!, {r12}
	ldmgeia r12!, {r8, r9}
	add r5,r5,r8,  asr r3
	add r7,r7,r9,  asr r3

	stmgeia r0!, {r4, r5}
	stmgeia r1!, {r6, r7}

	subs r14, r14, #2
	bne dec2loop

	ldmia   r13!, {r4-r12,pc}

*************************************************************************


and here is the C inline function .. not working


*************************************************************************


void dec2 (int *a0, int *a1, int *t[], int *param);

void dec2 (int *a0, int *a1, int *t[], int *param)
{
        asm (
				"stmdb r13!, {r4-r12, lr}\n\t"

                "ldmia %5!, {r6,r7}\n\t"
				"mov r14, r7\n\t"
				"mov r8, r6\n\t"
				"mov r3, r8\n\t"

"loop:\n\t"
                "ldmgeda %4!,  {r12}\n\t"
                "ldmgeia r12!, {r8, r9}\n\t"
                "ldmgeia %2,   {r4, r5}\n\t"
                "ldmgeia %3,   {r6, r7}\n\t"
                "add r4,r4,r8, asr r3n\t"
                "add r6,r6,r9, asr r3n\t"

                "ldmgeda %4!,  {r12}\n\t"
                "ldmgeia r12!, {r8, r9}\n\t"
                "add r5,r5,r8, asr r3\n\t"
                "add r7,r7,r9, asr r3\n\t"

                "stmgeia %0!,  {r4, r5}\n\t"
                "stmgeia %1!,  {r6, r7}\n\t"
                "subs r14, r14, #2\n\t"
                "bne loop\n\t"

				"ldmia r13!, {r4-r12,pc}\n\t"

                :"=r"(a0), "=r"(a1)
                :"0"(a0), "1"(a1), "r"(t), "r"(param)
				:"r3", "r4", "r5", "r6", "r7", "r8", "r9", "r12", "r14"
                );
}
*************************************************************************


Thanks in advance

Ganesh




More information about the Gcc-help mailing list