INVOKE Directive


The directive pushed arguments on the stack and calls a procedure. It is a convenient replacement for the instruction because multiple arguments can be passed by using a single line of code. The syntax is
     INVOKE  procedureName [, argumentList]
is an optional comma-delimited list of arguments passed to the procedure. Argument types are listed below:

Type Examples
Immediate value 10, 3000h, OFFSET myList, TYPE array
Integer expression (10 * 20), COUNT
Variable myList, array, myWord, myDword
Address expression [myList+2], [ebx+esi]
Register eax, bl, edi
ADDR name ADDR myList
OFFSET name OFFSET myList

An ABS Procedure
Using CALL Using INVOKE

 INCLUDE Irvine32.inc
 .data
  dummy  WORD  ?
 .code
 main PROC
      push  -23
      call  abs
      exit
 main ENDP
 
 ;; Find |value|
 abs PROC
      pop   edx    ; return address
      pop   eax    ; EAX = value
      cmp   eax, 0
      
       

             
      neg   eax
 
 POS: call  WriteInt
      push  edx
      ret
 abs ENDP
 END main

 INCLUDE Irvine32.inc
 .data
  dummy  WORD  ?
 .code

 ;; Find |value|
 abs PROC, value:SDWORD
      cmp   value, 0

      

              
      neg   value
 POS: mov   eax, value
      call  WriteInt
      ret
 abs ENDP
 
 ;; main proc is after abs proc.
 main PROC
      INVOKE  abs, -23
      exit
 main ENDP
 END main
An Execution Example An Execution Example

    +23

    +23






      “I’m not arguing, I’m just explaining why I’m right.”    
      ― Unknown