flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Atempt for SEH macroses.

Author
Thread Post new topic Reply to topic
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 16 Oct 2004, 08:17
Here is my first atempt to create simple macroses for handling exceptions.
The example use two levels of nested handlers and have some "interactiveness" to choose how to process exception.

Check the attached file. You have to compile the example with Fresh, but it needs editing of some of the standard includes. Changed files are attached too. Please read readme.txt files (they are two Smile ) for details.

Of course you can use any version of FASM, after some play with Win32 include files. The only file you actually need except example sources is "exceptions.inc"


Regards.


Description:
Download
Filename: SEH.zip
Filesize: 5.99 KB
Downloaded: 739 Time(s)

Post 16 Oct 2004, 08:17
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 16 Oct 2004, 10:33
Well, actually I have nothing to comment - you have coded try...catch statement (from C++) in assembly, it allows nesting... great work!

BTW, C++ also implements "finally" keyword, which defines a block that will be always executed (no matter if exception exists or not). I don't know if it is useful at all (you can always add common code after "endTry"), but I may be wrong.
Post 16 Oct 2004, 10:33
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 16 Oct 2004, 11:23
decard wrote:
you have coded try...catch statement (from C++) in assembly


Well, I don't know how exactly is the syntax in C++, but in Delphi there are two types of exception handlers: "try...except" and "try...finally". Actually "finally" statement is looking strange for me, as far as code after "endTry" (or whatever close statement in another languages) can make the same work... maybe it is introduced because of some "structural considerations" Smile.

Regards.
Post 16 Oct 2004, 11:23
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 16 Oct 2004, 11:27
Quote:
maybe it is introduced because of some "structural considerations"

so we don't need it in assembly language Wink
Post 16 Oct 2004, 11:27
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 16 Oct 2004, 16:52
Afaik "finally" is not part of the C++ language, but has been added as an extension by many vendors, including microsoft. Anyway: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccelng/htm/key_s-z_5.asp
Post 16 Oct 2004, 16:52
View user's profile Send private message Visit poster's website Reply with quote
beppe85



Joined: 23 Oct 2004
Posts: 181
beppe85 26 Oct 2004, 11:32
I haven't looked at your code but you said 'Actually "finally" statement is looking strange for me, as far as code after "endTry" can make the same work'. Could I write the sample code:

Code:
call AllocMem
try
  ...
finally
  call FreeMem
end;    


It should free the object in any case, but rethrow an exception if something goes wrong.

Forget this if you have this already.
Post 26 Oct 2004, 11:32
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.