* in front of instruction operand, GNU assembly, AMD64

无人久伴 提交于 2020-01-06 17:26:12

问题


I have been trying to learn to write assembly code for the AMD64 processor. I have been looking at code generated by gcc. Eventually, I began seeing instructions such as

    call *(%rax)

What is the * doing in front of the operand? Something like this came up in the System V ABI document I'm reading, and the answer to the above will help me continue on. Here is an example of the syntax used in context, taken from the System V ABI document itself:

    // 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:


In AT&T syntax, an indirect jump or function call has its operand prefixed with an asterisk * to distinguish it from a direct jump or function call. The purpose of this is to distinguish a call to a function from an indirect call to a function pointer stored in a variable:

call function
call *function_pointer


来源:https://stackoverflow.com/questions/41732843/in-front-of-instruction-operand-gnu-assembly-amd64

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!