*在指令操作数,GNU汇编,AMD64之前

时间:2017-01-19 02:40:44

标签: assembly x86-64 gnu

我一直在努力学习为AMD64处理器编写汇编代码。我一直在看gcc生成的代码。最后,我开始看到诸如

之类的说明
    call *(%rax)

在操作数前面做什么?在我阅读的System V ABI文档中出现了类似的内容,上面的答案将帮助我继续。以下是上下文中使用的语法示例,取自System V ABI文档本身:

    // System V ABI suggested implementation of a
    // C switch statement with case labels 0, 1, and 2,
    // and a default label.

    // Jump to the default case if the control variable is
    // less than 0.
         cmpl     $0, %eax
         jl      .Ldefault

    // Jump to the default case if the control variable is
    // greater than 2.
         cmp $2, %eax
         jg .Ldefault

         movabs   $.Ltable, %r11
         jmpq     *(%r11,%eax,8)  /* Here is that syntax. */

         .section .lrodata,"aLM",@progbits,8
         .align 8
    .Ltable: .quad .Lcase0
             .quad .Ldefault
             .quad .Lcase2
             .quad .previous
    .Ldefault:
         // Code for default case
    .Lcase0:
         // Code for case 0
    .Lcase1:
         // Code for case 1
    .Lcase2:
         // Code for case 2

1 个答案:

答案 0 :(得分:4)

在AT& T语法中,间接跳转或函数调用的操作数前缀为星号call function call *function_pointer ,以区别于直接跳转或函数调用。这样做的目的是区分对函数的调用和间接调用存储在变量中的函数指针:

has_and_belongs_to_many