2017-01-19 4 views
0

私は、AMD64プロセッサのアセンブリコードを書く方法を学びました。私はgccによって生成されたコードを見てきました。最終的に、私は指示を見るようになった*命令オペランドの前に、GNUアセンブリ、AMD64

call *(%rax) 

オペランドの前に*何をしていますか?このような何かが、私が読んでいるSystem V ABIの文書に現れました。そして、上記の答えが私を引き続き助けてくれるでしょう。ここでは、システムV ABIドキュメント自体から取られた文脈で使用する構文の例です:AT & T構文、間接ジャンプまたは関数呼び出しで

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

ポインタ逆参照演算子に似ています。 – mustaccio

+0

機械命令を組み立てたときに、機械コードなしで命令を組み立てたとき、何を見つけましたか? –

+2

アセンブリの中で\ *アドレス(printfにあるもの)の意味は何ですか?](http://stackoverflow.com/questions/2559849/what-does-addressfound-in-printf-mean-in-assembly) –

答えて

4

そのオペランドがそれを区別するために、アスタリスク*が付いています直接ジャンプまたは関数呼び出しから取得します。これは、関数呼び出しを間接呼び出しから変数に格納された関数ポインタと区別するためのものです。

call function 
call *function_pointer 
関連する問題