关于汇编示例

网友投稿 704 2022-11-30

关于汇编示例

关于汇编示例

#include int main(int argc, char *argv[]){ QCoreApplication app(argc, argv);#if 0//汇编右位移指令shr,左位移指令shl int a = 40; int b; asm ("movl %1, %%eax; \ shl %%eax; \ shl %%eax;\ movl %%eax, %0;" : "=r" (b) : "r" (a) : "%eax"); printf ("a = %d\nb = %d\n", a, b); system("pause");#endif#if 0//异或运算xor int a = 40; int b; asm ("movl %1, %%eax; \ xor %%eax,%%eax; \ movl %%eax, %0;" : "=r" (b) : "r" (a) : "%eax"); printf ("a = %d\nb = %d\n", a, b); system("pause");#endif#if 0//取反运算not int a = 40; int b; asm ("movl %1, %%eax; \ not %%eax; \ movl %%eax, %0;" : "=r" (b) : "r" (a) : "%eax"); printf ("a = %d\nb = %d\n", a, b); system("pause");#endif#if 0//或运算or int a = 40; int b; asm ("movl %1, %%eax; \ or %%eax,%%eax; \ movl %%eax, %0;" : "=r" (b) : "r" (a) : "%eax"); printf ("a = %d\nb = %d\n", a, b); system("pause");#endif#if 0//循环左移ROL,右移ROR int a = 6; int b = 0; asm ("movl %1, %%eax; \ rol %%eax; \ movl %%eax, %0;" : "=r" (b) : "r" (a) : "%eax"); printf ("a = %d\nb = %d\n", a, b); system("pause");#endif#if 0//循环左移ROL,右移ROR int s1 = 6; int s2 = 1; asm ("movl

#include int main(int argc, char *argv[]){ QCoreApplication app(argc, argv);#if 0//汇编右位移指令shr,左位移指令shl int a = 40; int b; asm ("movl %1, %%eax; \ shl %%eax; \ shl %%eax;\ movl %%eax, %0;" : "=r" (b) : "r" (a) : "%eax"); printf ("a = %d\nb = %d\n", a, b); system("pause");#endif#if 0//异或运算xor int a = 40; int b; asm ("movl %1, %%eax; \ xor %%eax,%%eax; \ movl %%eax, %0;" : "=r" (b) : "r" (a) : "%eax"); printf ("a = %d\nb = %d\n", a, b); system("pause");#endif#if 0//取反运算not int a = 40; int b; asm ("movl %1, %%eax; \ not %%eax; \ movl %%eax, %0;" : "=r" (b) : "r" (a) : "%eax"); printf ("a = %d\nb = %d\n", a, b); system("pause");#endif#if 0//或运算or int a = 40; int b; asm ("movl %1, %%eax; \ or %%eax,%%eax; \ movl %%eax, %0;" : "=r" (b) : "r" (a) : "%eax"); printf ("a = %d\nb = %d\n", a, b); system("pause");#endif#if 0//循环左移ROL,右移ROR int a = 6; int b = 0; asm ("movl %1, %%eax; \ rol %%eax; \ movl %%eax, %0;" : "=r" (b) : "r" (a) : "%eax"); printf ("a = %d\nb = %d\n", a, b); system("pause");#endif#if 0//循环左移ROL,右移ROR int s1 = 6; int s2 = 1; asm ("movl $0x01 , %%eax ; \n\t" "xorl %%edx , %%edx ;\n\t" "cpuid ;\n\t" "movl %%edx ,%0 ;\n\t" "movl %%eax ,%1 ; \n\t" :"=m"(s1),"=m"(s2)); printf ("a = %d\nb = %d\n", s1, s); system("pause");#endif#if 1 int a = 6; int b = 2; //asm volatile("movl %0,%1" : "=r" (b) : "m" (a)); asm volatile("addl %2,%0":"=r"(a): "r"(a),"r"(b)); printf ("a = %d\nb = %d\n", a, b); system("pause");#endif return app.exec();}

x01 , %%eax ; \n\t" "xorl %%edx , %%edx ;\n\t" "cpuid ;\n\t" "movl %%edx ,%0 ;\n\t" "movl %%eax ,%1 ; \n\t" :"=m"(s1),"=m"(s2)); printf ("a = %d\nb = %d\n", s1, s); system("pause");#endif#if 1 int a = 6; int b = 2; //asm volatile("movl %0,%1" : "=r" (b) : "m" (a)); asm volatile("addl %2,%0":"=r"(a): "r"(a),"r"(b)); printf ("a = %d\nb = %d\n", a, b); system("pause");#endif return app.exec();}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:@Scheduled fixedDelayString 加载properties配置方式
下一篇:opencv 多圆查找
相关文章

 发表评论

暂时没有评论,来抢沙发吧~