473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

GCC inline assembly

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
Nov 14 '05 #1
3 3642
Ganesh Tawde <ga**********@patni.com> 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.
Nov 14 '05 #2
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
Nov 14 '05 #3
In <1d**************************@posting.google.com > ga**********@patni.com (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: Da*****@ifh.de
Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: Brian Lindahl | last post by:
I'm using a temporary buffer to transfer some data and would rather not allocate it on the heap. The problem is that the size of the buffer is only known upon entry into the function that utilizes...
18
by: Method Man | last post by:
If I don't care about the size of my executable or compile time, is there any reason why I wouldn't want to inline every function in my code to make the program run more efficient?
30
by: Will Pittenger | last post by:
Does C# inline functions? I do not see a inline keyword. Is there an implicit inline? Can the compiler select functions for auto-inlining? I am more used to C++ where all these things are...
6
by: ThomasR | last post by:
I was wondering on the breadth of optimization with .NET JIT compiler. Let's presume I have an assembly of static classes - mostly helper functions. Some of these functions may be very small...
8
by: neilmcguigan | last post by:
I just wanted to list some reasons why I prefer inline code to code-behind. 1. you can fix some bugs more quickly. remote desktop into server, change the aspx file, and she's good to go. I'd say...
9
by: chinu | last post by:
hi all, i did a small experiment to grasp the advantages of declaring a function as inline. inline int fun1(); int main(){ unsigned int start=0,end=0; asm("rdtsc\n\t"
2
by: =?Utf-8?B?TWljayBPJ05laWxs?= | last post by:
I am currently trying to wrap an old library (ImageMagick) in .NET, and am having problems with inline expansions. I have recompiled the library in vc++ 2005 OK. However, when I try to access any...
15
by: Chris Peters | last post by:
Hello Group Can anyone confirm or suggest workrounds for the following bug in lccwin32. If an inline assembly statement immediately follows a for loop and you try to set a breakpoint on it, then...
4
by: raashid bhatt | last post by:
hi by the definition of inline functions "In computer science, an inline function is a programming language construct used to suggest to a compiler that a particular function be subjected to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.