Author Topic: PROC and prolog/epilog  (Read 1256 times)

markallyn

  • Member
  • **
  • Posts: 137
Re: PROC and prolog/epilog
« Reply #45 on: December 09, 2017, 10:50:26 AM »
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

  • Member
  • *****
  • Posts: 7900
  • Assembler is fun ;-)
    • MasmBasic
Re: PROC and prolog/epilog
« Reply #46 on: December 09, 2017, 11:14:16 AM »
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.

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)


felipe

  • Member
  • ***
  • Posts: 420
  • Asssssssembly language...said the snake.
Re: PROC and prolog/epilog
« Reply #47 on: December 09, 2017, 12:14:33 PM »
 :P
Felipe.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5043
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: PROC and prolog/epilog
« Reply #48 on: December 09, 2017, 01:00:52 PM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

aw27

  • Member
  • ****
  • Posts: 977
  • Let's Make ASM Great Again!
Re: PROC and prolog/epilog
« Reply #49 on: December 09, 2017, 02:43:34 PM »
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

  • Member
  • ****
  • Posts: 977
  • Let's Make ASM Great Again!
Re: PROC and prolog/epilog
« Reply #50 on: December 09, 2017, 02:50:40 PM »
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

  • Member
  • *****
  • Posts: 7900
  • Assembler is fun ;-)
    • MasmBasic
Re: PROC and prolog/epilog
« Reply #51 on: December 09, 2017, 07:48:40 PM »
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.

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

aw27

  • Member
  • ****
  • Posts: 977
  • Let's Make ASM Great Again!
Re: PROC and prolog/epilog
« Reply #52 on: December 09, 2017, 09:09:18 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

  • Member
  • **
  • Posts: 137
Re: PROC and prolog/epilog
« Reply #53 on: December 10, 2017, 05:29:22 AM »
Hello everyone,

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

Mark

markallyn

  • Member
  • **
  • Posts: 137
Re: PROC and prolog/epilog
« Reply #54 on: December 10, 2017, 05:34:27 AM »
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

  • Member
  • **
  • Posts: 137
Re: PROC and prolog/epilog
« Reply #55 on: December 10, 2017, 06:06:17 AM »
aw27:

With respect to your statement:

Quote
he 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

  • Member
  • ****
  • Posts: 977
  • Let's Make ASM Great Again!
Re: PROC and prolog/epilog
« Reply #56 on: December 10, 2017, 06:31:18 PM »
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.