News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

PROC and prolog/epilog

Started by markallyn, November 28, 2017, 08:04:12 AM

Previous topic - Next topic

markallyn

aw27 and Jokaste and Hutch,

aw27. Yes, absolutely Kusswarm was after SEH type code and that's why he does what he does.  And, as you say, apparently no one on the forum cares about SEH.  And, yes you are also right that Kusswarm's NUM_PUSHREG reffers to pushed registers and not parameters.  I debated whether to change the name to PUSH_PARMS, but let it stand as is.  Why bother with what I did.? This goes to Jokaste's query.

Jokaste and aw27:  The goal originally was to understand what PROC actually does...and I gradually drifted off this and towards the code you see before you.  As I discovered, if one includes \masm32\include\64\masm64rt.inc then one causes STACKLIB macro to be run and this generates the ENTER\LEAVE pair.  If NOSTACKLIB is run, then one gets a "bare bones" PROC and one must create a frame if it's needed.  But I drifted past this "discovery" and began to wonder if it was possible to interactively define a suitable stack frame for the 64-bit ABI.  After considerable mucking about the above code resulted and mostly thanks to reading Kusswarm's code late in his book.  Primarily, this whole business was me learning how the blasted ABI actually works if there are more than 4 parameters.

Hutch:  I will post a .zip file.  Should have thought about this.  Apologies to all.

Mark

jj2007

Quote from: markallyn on December 09, 2017, 10:50:26 AMKusswarm was after SEH type code and that's why he does what he does.  And, as you say, apparently no one on the forum cares about SEH.

Yes, we love to see code crash :greenclp:

Seriously: José has done a great job exploring SEH in 64-bit land, but many assembler programmers believe in code that either works or crashes - no half-baken compromises.

Btw the guy's name is Kusswurm. The origin is German, "Kusswarm" would mean "as warm as a kiss", Kusswurm is something like a kissing worm - I sincerely hope he got used to it. He offers a freely downloadable guide to using Masm in Visual Studio. By reading only 28 pages, you will be able to build a Hello World project in Micros**t's flagship IDE. Hurry up and get it, as it will not be compatible with the coming version of Visual Crap 8)



hutch--

While I confess to being a dinosaur in coding style where you get it right or it explodes in your face and makes you look like a jerk, SEH does have its place, even in properly written error free code with hardware based tasks where control of the required capacity cannot be done in software. Outside of specific hardware related issues, a "no error handler" approach makes your debugging a lot simpler and your code a lot more reliable. Get it exactly right and it works correctly without hand holding, make a mess of it and it very clearly tells you that it did not work.

aw27

Quote
I debated whether to change the name to PUSH_PARMS, but let it stand as is.
The called function doesn't have to care about the influence of the function parameters on the alignment. This is done by the caller.

aw27

Quote
but many assembler programmers believe in code that either works or crashes

That is not really the reason. The reason is that if you don't use SEH you will have problems integrating the ASM with a high-level language like C or C++ without disabling SEH for the whole application. And 99% of people that use ASM in the real World use it in this fashion.

jj2007

Quote from: aw27 on December 09, 2017, 02:50:40 PMThe reason is that if you don't use SEH you will have problems integrating the ASM with a high-level language like C or C++ without disabling SEH for the whole application.

Will the C application that loads an asm dll or links to an asm object file notice that there is no SEH?

aw27

Quote from: jj2007 on December 09, 2017, 07:48:40 PM
Will the C application that loads an asm dll or links to an asm object file notice that there is no SEH?
When building in release mode, Visual Studio uses to notice. This may not apply to other tools. I don't think it will apply as well to asm dlls.

markallyn

Hello everyone,

In response to Hutch's suggestion yesterday I have attached .zip file containing the caller and callee asm sources. 

Mark

markallyn

Let me offer sincerest apologies to Daniel Kusswurm for mangling his name.  I suppose the mistake crept in because I thought a warm kiss much more appealing than kissing worms.

Mark

markallyn

aw27:

With respect to your statement:

Quotehe called function doesn't have to care about the influence of the function parameters on the alignment. This is done by the caller.

Exactly so.  It took me doing this bizarre program tediously over several days of dead-ends to discover this very basic fact.

Mark

aw27

Quote from: markallyn on December 10, 2017, 06:06:17 AM
It took me doing this bizarre program tediously over several days of dead-ends to discover this very basic fact.
Not bad, some people take years and others haven't got it yet.