News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Try/Catch

Started by korte, January 23, 2009, 06:14:46 PM

Previous topic - Next topic

korte




procedure test_try

Try
xor eax,eax
call test_proc
inc eax
call test_proc

Catch

endTry

ret

endProc

test_proc proc

.if eax!=0
Raise test_try
.endif

ret
test_proc endp


Macro's

procedure MACRO nam:REQ
   lastproc equ nam
   arg equ <>
   arg CATSTR arg,<nam >
   arg CATSTR arg,< proc >
   arg
   endm

endProc macro
   lastproc endp
   endm


Try macro
   arg CATSTR <_try_>,lastproc,<:>
   arg

   arg CATSTR <   mov _esp_>,lastproc,<,esp>
   arg

   endm

Catch   macro
   arg CATSTR <   jmp _endtry_>,lastproc
   arg

   option NOSCOPED
   arg CATSTR <_catch_>,lastproc,<:>
   arg
   db 066h, 0b8h ; mov eax
   arg CATSTR <_esp_>,lastproc,<   dd UNDEF>
   arg
   mov esp,eax
   option SCOPED
   endm

endTry macro
   arg CATSTR <_endtry_>,lastproc,<:>
   arg
   endm

Raise macro p1,p2
   ifdef p2
      mov eax,p2
   endif
     jmp _catch_&p1&
   endm