小编use*_*906的帖子

gcc内联汇编错误"mov的操作数类型不匹配"

//quick inline asm statements performing the swap_byte for key_scheduling
inline void swap_byte(unsigned char *x, unsigned char *y)
{
 unsigned char t;
 asm("movl %1, %%eax;"
     "movl %%eax, %0;"
     :"=r"(t)
     :"r"(*x)
     :"%eax");
 asm("movl %1, %%eax;"
     "movl %%eax, %0;"
     :"=r"(*x)
     :"r"(*y)
     :"%eax");
 asm("movl %1, %%eax;"
     "movl %%eax, %0;"
     :"=r"(*y)
     :"r"(t)
     :"%eax");       
}
Run Code Online (Sandbox Code Playgroud)

在这里,我想从交换焦炭x和存储y,与同为yx.我已经通过更改movl来编译这些指令mov但没有成功.编译/链接的问题在哪里?

这是cygwin中编译的输出:

$ gcc rc4_main.c -o rc4ex
/tmp/ccy0wo6H.s: Assembler messages:
/tmp/ccy0wo6H.s:18: Error: operand type mismatch for `mov'
/tmp/ccy0wo6H.s:18: Error: …
Run Code Online (Sandbox Code Playgroud)

c assembly gcc inline-assembly

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

assembly ×1

c ×1

gcc ×1

inline-assembly ×1