; Listing7-3.asm
;
; A program that demonstrates throwning
; an exception with the raiseException
; API call.


            option     casemap:none
            .nolist
            include    aoalib.inc
            includelib aoalib.lib
            .list
            
            .const

; Program title:

             align  word
ttlStr       byte   "Listing 7-3", 0

            
            .code

;--------------------------------------------------
;
; Here is the main assembly language function.

            
            public  asmMain
            
            extern  RaiseException:proc
            
            
            align       8
            qword       ?   ;Also for hot patching
            
asmMain     proc        frame 

            db          48h ;REX prefix for hot swapping.
            push        rbp ; save previous frame pointer
            .pushreg    rbp ; encode unwind info
            mov         rbp, rsp ; set new frame pointer
            .setframe   rbp, 0 ; encode frame pointer
            sub         rsp, 40h
            .allocstack 40h
            .endprolog


            mov rcx,0FFh    ;Exception code
            mov rdx,0       ;Exception flags
            mov r8,0        ;Number of arguments
            mov r9,0        ;Pointer to arguments
            call RaiseException

            
            mov         rsp, rbp
            pop         rbp
            ret
        
asmMain     endp
            end
