cs375 p. 234

Contents Page-10 Prev Next Page+10 Index

Function Calls

For external functions, it is necessary to:

  1. Set up the arguments for the function call.

  2. Call the function.

  3. Retrieve the result and do any necessary final actions.

A function call involves the following:

  1. Load arguments into registers:
    • First integer argument in %edi

    • For string literal, address in %rdi using leaq (Load Effective Address, Quad):
       leaq .LC4(%rip),%rdi # addr literal .LC4
      

    • First floating argument in %xmm0

  2. Execute a call instruction[PLT is the Procedure Linkage Table for dynamically linked procedures.]:

     call sin@PLT
    

  3. Floating results are returned in %xmm0. Integer results are returned in %eax or %rax.

AltStyle によって変換されたページ (->オリジナル) /