Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > GCC inline assembly

Reply
Thread Tools

GCC inline assembly

 
 
Ganesh Tawde
Guest
Posts: n/a
 
      04-23-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
 
Reply With Quote
 
 
 
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      04-23-2004
Ganesh Tawde <> spoke thus:

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

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
 
Reply With Quote
 
 
 
 
Allin Cottrell
Guest
Posts: n/a
 
      04-24-2004
Ganesh Tawde wrote:
>
> 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
 
Reply With Quote
 
Dan Pop
Guest
Posts: n/a
 
      04-26-2004
In < > (Ganesh Tawde) writes:

>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
--
Dan Pop
DESY Zeuthen, RZ group
Email:
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tool which expands implicitly inline inline functions tthunder@gmx.de C++ 3 06-16-2005 12:54 AM
To inline or not to inline? Alvin C++ 7 05-06-2005 03:04 PM
Function delcared inline but not defined inline Nish C Programming 4 10-08-2004 03:31 PM
External inline functions calling internal inline functions Daniel Vallstrom C Programming 2 11-21-2003 01:57 PM
inline or not to inline in C++ Abhi C++ 2 07-03-2003 12:07 AM



Advertisments