在__asm__中,“$ variable”是什么意思?

时间:2015-04-18 20:37:06

标签: assembly x86 inline-assembly gas

int context(){"\
       movl $0, %eax;\
       push $xxxxx;\
       push $0;\
       push %eax;\
       ...........
       xxxxx : leave;\
       ret;");
}

我是初学者。

在上面的源代码中,我无法理解" $ xxxxx"的含义。 我认为符号' $'只是在不变的前面。

而且,我从未见过最后两行。 我知道离开和退出指令,但" xxxxx:"形式是如此陌生。 我无法找到这样的例子。

1 个答案:

答案 0 :(得分:1)

$前缀表示GNU汇编程序的AT& T语法中的立即操作数。见https://sourceware.org/binutils/docs/as/i386_002dVariations.html#i386_002dVariations

  

AT& T立即操作数之前是' $';

该行:

xxxxx : leave;

使用xxxxx作为标签(https://sourceware.org/binutils/docs/as/Labels.html#Labels)。

  

标签被写为符号后面紧跟冒号`:'

在您想知道的情况下,标签xxxxx的值是直接操作数。