News:

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

Main Menu

Operand types with AVX instructions

Started by dstanfill, August 31, 2016, 09:40:45 AM

Previous topic - Next topic

rrr314159

Those who answer questions with questions are doomed to rot in the nth circle of Hell for eternity. Just thought I'd warn you :-)

Good error messages are very desirable. And since the parameter list of a typical function (API calls, not so much one's own functions) is known, and fixed (barring VARARG), then sure, makes sense to give an error if it's typed in wrong. But how much trouble is needed to provide that error message? PROTO's can be a hassle, as we all know.

To use a function like CreateWindowEx, one has to understand it quite thoroughly, consulting the MS documentation. There are many necessary conditions, only one of which is the number of parameters. All the rest of the info is much more important: what each parameter does, which calls must precede CreateWindow, and so forth. In C, with strong typing, there's more justification for checking parameters. For instance it might have a DWORD which could be a handle, an unsigned integer, real, whatever. If you're using a wrong type, that's likely to be an error. But asm just checks DWORD vs BYTE, etc, not very informative; and, of course, the number of them. Is this small amount of info worth the trouble of PROTO's? How can one understand the function well enough to use it, and not be able to count the parameters? And if you do put in an extra NULL, usually it just blows up in your face, so you know something's wrong.

Also, the vast majority of API calls have just zero, one, up to four maybe, parameters. Hardly worth checking.

Finally, probably the majority of API calls, in actual programming practice, are cut-and-pasted. Particularly complicated ones, like CreateWindow. In fact we cut-and-paste the entire section for Window creation, including calls before and after. The first time you use it, you must study it carefully, understand each parameter, and related functionality. Counting up to 12 is far less than 1% of the overall effort. Afterwards you'll probably just cut and paste this standard block of code.

I'm not against error checking "on principle". There isn't one right answer here. Has nothing to do with RealMan(TM)-hood. It's just a question whether the trouble of PROTO'ing is really worth the effort.

As for the rhetorical q, what's invoke for?: it's very convenient to line up the parameter list on one line instead of having to load up the stack (or r8, r9 etc) in the preceding lines. Back when it wasn't built-in everyone rolled their own invoke (or "mycall", whatever) macro, for this reason. There's also the other clauses, USES etc, that can be convenient.
I am NaN ;)

jj2007

Quote from: rrr314159 on September 04, 2016, 10:52:32 AMif you do put in an extra NULL, usually it just blows up in your face, so you know something's wrong.

Usually, LEAVE takes care of the stack, and will make sure that your USES does not what you expect it to do. It will be fun 8)


QuoteIt's just a question whether the trouble of PROTO'ing is really worth the effort.

Instead of whining about this incredible effort, have a look at \Masm32\MasmBasic\Res\pt.inc, line 151ff

rrr314159

I avoid enter / leave, it can hide mistakes.

jj2007 wrote: "whining about this incredible effort"
I am NaN ;)