Function Call


A function call in assembly language simply requires pushing the arguments to the function onto the stack in reverse order, and issuing a call instruction. After calling, the arguments are then popped back off of the stack. For example, consider the C code:

  printf("The number is %d", 88); 

In assembly language, this would be rendered as:

  .section .data  text_string:  .ascii "The number is %d\0"  .section .text  pushl $88  pushl $text_string  call  printf  popl  %eax  popl  %eax      #%eax is just a dummy variable,                  #nothing is actually being done                  #with the value. You can also                  #directly re-adjust %esp to the                  #proper location. 




Programming from the Ground Up
Programming from the Ground Up
ISBN: 0975283847
EAN: 2147483647
Year: 2006
Pages: 137

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net