[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to avoid optimization of inline assembly?
From: |
nospam |
Subject: |
How to avoid optimization of inline assembly? |
Date: |
Thu, 23 Sep 2004 12:29:00 +0800 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040805 Netscape/7.2 |
Dear sir,
Consider the following code on ARM platform:
#include <stdio.h>
#include <stdlib.h>
static void
my_memcpy(void *dest, void *src, int num_short_to_cpy,
int num_to_repeat) {
// Note: dest=r0, src=r1, num_short_to_cpy=r2, num_to_repeat=r3;
asm (
";
.L_MEMCPY0:;
cmp r2, #0;
ble .L_MEMCPY3;
ldrb r4, [r1], #1;
ldrb r5, [r1], #1;
mov r6, r3;
.L_MEMCPY1:;
cmp r6, #0;
ble .L_MEMCPY2;
strb r4, [r0], #1;
strb r5, [r0], #1;
sub r6, r6, #1;
b .L_MEMCPY1;
.L_MEMCPY2:;
sub r2, r2, #1;
b .L_MEMCPY0;
.L_MEMCPY3:;"
:
:
:"r4", "r5", "r6" /*reserve r4 and r5*/
);
}
int
main(int argc, char **argv) {
short a[10]={0xABCD, 0x1234, 0x5678};
short b[10];
my_memcpy(b, a, 2, 2);
fprintf(stderr, "hello\n");
fprintf(stderr, "%x %x %x %x\n", a[0], a[1], a[2], a[3]);
fprintf(stderr, "%x %x %x %x\n", b[0], b[1], b[2], b[3]);
// fprintf(stderr, "%s\n", a);
// fprintf(stderr, "%s\n", b);
}
I tried to compile the code with -O3 flag and somehow all the inline
assembly code are "optimized" which I optimized myself.
How can i prevent the inline assembly from being "optimized"?
Yick
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
- How to avoid optimization of inline assembly?,
nospam <=