News:

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

Main Menu

ml64 vs uasm64 syntax for proto

Started by jimg, July 26, 2018, 06:36:24 AM

Previous topic - Next topic

jimg

This line-
         QueryInterfaceProto   TYPEDEF PROTO lpThis:LPTHIS,iid:REFIID,ppvObject:PPVOID
gives this error-
         Error A2091: Language type must be specified

I don't have a masm 64 reference manual, but the 32 bit manual says language is optional.

hutch--


jimg

This line came from \masm32\include64\win64.inc, so I'm not understanding something here.  What is the purpose of the line if it's not a proto?

hutch--

It probably has to do with it being a TYPEDEF. Vasily wrote some of this stuff so I can really help you there. If you are writing 64 bit MASM, you don't use prototypes.

jimg

Okay, I can believe that the error is because it's a typedef, not a proto.
I think it's still a problem that it's accepted in ml64 but not uasm64.
And still, if ml64 doesn't use protos, shouldn't win64.inc be fixed up?

hutch--

Jim,

I don't have time for a wild goose chase, take my word for it that ML64 does not use prototypes, if you have the time to waste, write a prototype for a test procedure then enter the wrong data to call the procedure and the prototype will do nothing. ML64 does not use them.

jj2007

Quote from: hutch-- on July 27, 2018, 03:54:08 AMwrite a prototype for a test procedure then enter the wrong data to call the procedure and the prototype will do nothing. ML64 does not use them.

ML64 is really an ill-mannered pig, but it can be taught to behave better:

include \Masm32\MasmBasic\Res\JBasic.inc
Init           ; OPT_64 1      ; put 0 for 32 bit, 1 for 64 bit assembly
  jinvoke MessageBox, 0, Chr$("This code was assembled with ", @AsmUsed$(1), " in ", jbit$, "-bit format"), Chr$("This will build fine"), MB_OK
  ; jinvoke MessageBox, Chr$("This will not build"), MB_OK ; error: ## not enough arguments for MessageBox ##
EndOfCode


Can be built with UAsm, too 8)

KradMoonRa

#7
Hi, not big deal but ML64 automatic do cdecl calling for all types protos and proc, but uasm its off for user selection of preferred calling convention for WIN64.

its possible to pass the .inc with an UASM option to add the calling, langtype for protos and procs.

Example
file.asm

.x64
;option casemap:none  ; small case option for typed know types PROTO|proto, PROC|proc etc
option frame:auto
option stackbase:rbp ; RSP or RBP are supported options for the stackbase.
option win64:7 ; 11-15 for RSP and 1-7 for RBP.

option language:C ; Available languages, WIN32 = CDECL = C, FASTCALL, STDCALL. WIN64 = CDECL, FASTCALL(ignored but compiles), STDCALL, VECTORCALL.

win64.inc

yourcode......



The uasmlib

hutch--

 :biggrin:

    jinvoke MessageBox, 0, Chr$("This code was assembled with ", @AsmUsed$(1), " in ", jbit$, "-bit format"), Chr$("This will build fine"), MB_OK

MASM
    invoke MessageBox,hWnd,"This was built in Microsoft Assembler","About MASM",MB_OK

I rest my case.  :P

jj2007

In this specific case, both versions will produce a similar MessageBox. The difference is that you can forget the hwnd, and your code will still build. And crash. My jinvoke will just refuse to build, and tell you what your problem is: error: ## not enough arguments for MessageBox ##

What was the purpose of the real invoke macro introduced twenty years ago?

aw27

Quote
Error A2091: Language type must be specified
What ML64 version are you using? The latest and greatest or the oldest you could find?  :badgrin:

mineiro

hello sir jimg;
As you perceived ml64 don't do parameters check from function prototypes. Depending how you code you have an option that is switch to masm32 only to do that, just to see if you receive an error message. I was doing this way when I was starting, switching between both.
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

hutch--

 :biggrin:

> The difference is that you can forget the hwnd, and your code will still build.

The difference is assembler programmers know the argument count of an external procedure, ML64 is not a consumer product, it is an industrial product that does not hold your hot little hand. The only assembler in 64 bit that is MASM compatible is MASM.  :P

> What was the purpose of the real invoke macro introduced twenty years ago?

The obvious, to hold your hot little hand. In 64 bit, who cares.  :eusa_boohoo:

zedd151

Would have been a lot easier if the original design for MASM(32 bit or even 16  :P ) in general, were to pass args to the called procedure in registers.

A lot of people are so used to using
push x
push x
push x
push x
call procedure

or
invoke procedure, x, x, x, x.

Makes my brain hurt, trying to do it any other way. I guess I don't have the 'right stuff' for 64 bit coding in MASM.

hutch--

Z,

In the days of YAW (16 bit MS-DOS) arguments were passed in registers to system functions when interrupts did not mean an unreliable means of contraception. PUSH / CALL syntax worked OK but it made for slower code and increased complexity. With the advent of 64 bit x86-64 processors with twice as many registers, its a no brainer to use them to pass arguments as a vast number of API calls and procedures have 4 or less arguments., now its reg, reg, reg, reg, write to stack, write to stack etc ....  :P