GCC inline assembly

G

Ganesh Tawde

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
 
C

Christopher Benson-Manica

Ganesh Tawde said:
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?

Your post is off-topic for comp.lang.c. Please visit

http://www.ungerhu.com/jxh/clc.welcome.txt
http://www.eskimo.com/~scs/C-faq/top.html
http://benpfaff.org/writings/clc/off-topic.html

for posting guidelines and frequently asked questions. Thank you.
 
A

Allin Cottrell

Ganesh said:
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?

Perhaps someone on gnu.gcc.help

Allin Cottrell
 
D

Dan Pop

In said:
I am trying to use the below pure assembly code as inline assembly in
C.

Sorry, but the C programming language does not provide any support for
inline assembly.

If you need a gcc-specific solution (as your subject line suggests),
then read the gcc documentation (the real thing, not the man page).

GNU C does support inline assembly, but the issue is too complex to
be answered (other than by RTFM) even in a newsgroup dedicated to
helping gcc users.

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top