; Listing9-2.asm
;
; A program that demonstrates an indirect
; procedure call.


            option     casemap:none
            .nolist
            include    aoalib.inc
            include    aoaProcs.inc
            includelib aoalib.lib
            .list
            
; Program title:

            .const
             align  word
ttlStr       byte   "Listing 9-2", 0

            .code

; Sample procedure to indirectly call:

PassMe      proc    
            call    print
            byte    "PassMe was called",nl,0
            ret
PassMe      endp

; procedure CallPassMe( var func:procedure )

            parms   CallPassMe, rbp, 16, func:qword
CallPassMe  proc    
            push    rbp
            mov     rbp, rsp
            call    CallPassMe$func
            pop     rbp
            ret
CallPassMe  endp

;--------------------------------------------------
;
; Here is the main assembly language function.
            
            public  asmMain
            locals  asmMain, i:dword, a:dword[11]
asmMain     proc
            push    rbp
            mov     rbp, rsp
            sub     rsp, 80
            
            lea     rcx, PassMe     ;Pass address of PassMe
            mov     [rsp], rcx      ; on the stack.
            call    CallPassMe
            
            leave
            ret
        
asmMain     endp
            end