gcc内嵌汇编

dev c++使用gcc编译器,下面遇到必须C代码中嵌入汇编指令。

示例程序(读取CPU的相关参数):

unsigned long veax=1,deax,debx,decx,dedx;
__asm__
(
"movl %4,%%eax\n"
"cpuid\n"
"movl %%eax,%0\n"
"movl %%ebx,%1\n"
"movl %%ecx,%2\n"
"movl %%edx,%3"
:"=m"(deax),"=m"(debx),"=m"(decx),"=m"(dedx)
:"a"(veax)
:"ebx","ecx","edx","memory"
);

具体规则详见:http://wenku.baidu.com/link?url=rzgQlSCTW6jCSEMLVFTBPEbJEz_Wpv1e-fEw4d6GpEX9IwLT3cQAzxviPWI8siBZS8poGla68AhGNJ9IT5ZV7ccAvSC3qPDq-Y4jjXN9r9S

http://www.cnblogs.com/byeyear/p/4675049.html

posted @ 2016-10-29 23:39  qczhang  阅读(198)  评论(0编辑  收藏  举报