インラインアセンブリでいろいろやってみたいと思っています。
今度は配列から値を読みだしたり、代入したりする方法について質問させていただきます。
配列をソートするプログラムを作りたいです。
以下のコードだと、
(ファイル名) In function `test':
21 (ファイル名) syntax error before ',' token
というエラーが出ます。
お願いします。
#include <stdio.h>
void test(int*);
int main(void) {
int in[2];
in[0]=123;
in[1]=456;
test(in);
printf("%d %d\n",in[0],in[1]);
return 0;
}
void test(int* in) {
asm volatile (
"mov %2(,$0,4),%%eax \n\t"
"mov %2(,$1,4),%%ebx \n\t"
"mov %%eax,%2(,$1,4)\n\t"
"mov %%ebx,%2(,$0,4)\n\t"
: "m" (in)
: "%eax" , "%ebx"
);
}