- 论坛徽章:
- 3
|
回复 6# shaohui973
"movl $4, %%eax\n\t"
"int $0x80\n\t"
:“=m” (whatever)
:"m"(pcStr),"m"(dwLen)
: );
有点类似于堆栈. whatever, pcStr,dwLen这些参数一起入栈,先入栈的第一个为%0,第二个%1这样依此类推。所以这里的%0是whatever, %1是pcStr, %2是dwLen.
当去掉whatever操作数时,
"movl $4, %%eax\n\t"
"int $0x80\n\t"
:
:"m"(pcStr),"m"(dwLen)
: );
%0则是pcStr, %1则是dwLen.
当你使用“0”“1”这样的数字约束时, Gcc-inline-assembly中有提到, 该操作数是作为输入和输出使用.
"movl $4, %%eax\n\t"
"int $0x80\n\t"
:“=m” (whatever) “=m” (whocare)
:"0"(whatever),"1"(whocare)
: );
典型的用法是这样子的.这样gcc就会把whatever从内存读入, 同时输出到内存中同一位置。whocare同理. |
|