public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* [Fwd: ARM GCC inline assembly]
@ 2004-04-24  7:52 Ganesh Tawde
  2004-04-25  1:11 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: Ganesh Tawde @ 2004-04-24  7:52 UTC (permalink / raw)
  To: gcc-help

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Fwd: ARM GCC inline assembly]
  2004-04-24  7:52 [Fwd: ARM GCC inline assembly] Ganesh Tawde
@ 2004-04-25  1:11 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2004-04-25  1:11 UTC (permalink / raw)
  To: Ganesh Tawde; +Cc: gcc-help

"Ganesh Tawde" <ganesh.tawde@patni.com> writes:

> 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?

Compile with --save-temps, and compare the .s file generated from the
C code to the assembler code which is known to work.  Perhaps that
will suggest something.

Ian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-04-25  1:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-24  7:52 [Fwd: ARM GCC inline assembly] Ganesh Tawde
2004-04-25  1:11 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).