INVOKE Directive


The INVOKE directive pushed arguments on the stack and calls a procedure. It is a convenient replacement for the CALL instruction because multiple arguments can be passed by using a single line of code. The syntax is

 
     INVOKE  procedureName [, argumentList]
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   An ABS Procedure Using INVOKE 

 
 INCLUDE Irvine32.inc

 
 .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

 
 .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


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