; Example program showing the use of the SEH macros
; X-Calibre (X-Calibre@bigfoot.com - http://diamondcrew.cjb.net)

.386
.Model Flat, StdCall

include windows.inc
include user32.inc

include SEH.inc

includelib user32.lib

.code
tst	PROC
	THROW	0E0000001h
	ret
tst	ENDP

start:
main	PROC
	TRY
		sub		edx, edx
		mov		ecx, 0
		idiv	ecx

	CATCH(EXCEPTION_INT_DIVIDE_BY_ZERO)
		.data
		exceptionMsg	BYTE	"Exception occured",0

		.code
		INVOKE	MessageBox, NULL, ADDR exceptionMsg, ADDR exceptionMsg, MB_OK
	ENDC

main	ENDP

blah	PROC
	TRY
		call	tst
	FINALLY
		.data
		finallyMsg	BYTE	"In FINALLY-block",0

		.code
		INVOKE	MessageBox, NULL, ADDR finallyMsg, ADDR finallyMsg, MB_OK
	ENDF
blah	ENDP

	.data
	finishMsg	BYTE	"Program finished",0

	.code
	INVOKE	MessageBox, NULL, ADDR finishMsg, ADDR finishMsg, MB_OK

	ret
end start


