The MASM Forum

64 bit assembler => 64 Bit Assembler => Topic started by: TouEnMasm on July 07, 2020, 11:36:38 PM

Title: ML64 BNF GRAMMAR
Post by: TouEnMasm on July 07, 2020, 11:36:38 PM
There is on the microsoft site,a page dedicated to the BNF grammar of ml64,i find this interesting
Quote
invokeArg
    register :: register | expr | ADDR expr
invokeDir
    INVOKE expr ⟦ , ⟦ ;; ⟧ invokeList ⟧ ;;
invokeList
    invokeArg | invokeList , ⟦ ;; ⟧ invokeArg
Quote
I thing you see the one very interesting:INVOKE expr ⟦ , ⟦ ;; ⟧ invokeList ⟧ ;;
All i get is "INVOKE syntax error",any help ?



Title: Re: ML64 BNF GRAMMAR
Post by: hutch-- on July 07, 2020, 11:52:00 PM
Yves,

I learnt early in the piece not to take much notice of what people posted about how to use 64 bit MASM as it was almost exclusively nonsense. Few grasped the details of the Win64 calling convention or how the stack worked. The only solution was to write and test using a debugger to see what ended up where. Default 64 bit MASM does not provide many of the things that the 32 bit version did and it meant writing macros to do those things but it freed you from old assumptions and let you code the macros to do it in a clear reliable way.
Title: Re: ML64 BNF GRAMMAR
Post by: TouEnMasm on July 10, 2020, 04:28:12 PM

It was just a dream,that is view ml64 generate an error in an invoke statement if there is an error in the call.
Msdn say "invoke supported only in 32 bits"
Is there not a way by MACRO to verify the number and size of arguments  ?
Title: Re: ML64 BNF GRAMMAR
Post by: hutch-- on July 10, 2020, 05:26:59 PM
It can be done by a very messy technique but the simple answer is use the right number of arguments and data types. Once you are free of endless prototyping, you code so much faster and you would not go back.
Title: Re: ML64 BNF GRAMMAR
Post by: Vortex on July 10, 2020, 06:00:51 PM
Hi ToutEnMasm,

Here is an attempt to check the number of parameters :

http://masm32.com/board/index.php?topic=6153.msg65279#msg65279

You can write a better version of that macro but it's preferable to use the right number of arguments and data types as Hutch said.
Title: Re: ML64 BNF GRAMMAR
Post by: jj2007 on July 10, 2020, 11:05:36 PM
Is there not a way by MACRO to verify the number and size of arguments  ?

Sure there is: MultiByteToWideChar wants 6 arguments
- if you forget one, you get forced error : ## not enough arguments for MultiByteToWideChar ##
- if you add one more, it will choke with forced error : ## too many arguments for MultiByteToWideChar ##
The real fun is CreateWindowEx with 11 arguments, but according to Hutch a real assembly programmerTM does not need a macro to hold his hot little hand :cool:
Code: [Select]
include \Masm32\MasmBasic\Res\JBasic.inc ; ## console demo, builds in 32- or 64-bit mode with UAsm, ML, AsmC ##
MyText db "Добро пожаловать", 0         ; "Welcome" in Russian
MyTextW dw 100 dup(?)                 ; OPT_Assembler ML
HelloWorld dw "H", "i", 0         ; OPT_64 1 ; put 0 for 32 bit, 1 for 64 bit assembly
Init
  PrintLine Chr$("This program was assembled with ", @AsmUsed$(1), " in ", jbit$, "-bit format.")
  jinvoke MultiByteToWideChar, 65001, 0, addr MyText, -1, addr MyTextW, 100
  jinvoke MessageBoxW, 0, addr MyTextW, addr HelloWorld, MB_OK
EndOfCode
Title: Re: ML64 BNF GRAMMAR
Post by: hutch-- on July 11, 2020, 01:31:19 AM
 :biggrin:

Yeah,

You have to watch those hot little hands, they obviously don't belong to real men[TM]. Once you no longer have to rat around for the prototype or worse, have to keep editing the prototype while you are designing the procedure, you are set free to write fast code quickly and as far as arg count errors, you have a perfect technique that has worked well for years, it crashes around your ears and make a jerk out of you.

People who work at the coal face make far fewer mistakes because they know that it will crash like a ton of bricks if they stuff it up.
Title: Re: ML64 BNF GRAMMAR
Post by: TouEnMasm on July 11, 2020, 02:52:02 AM
Macro perhaps or other things perhaps also,I have the choice of the soluce.
Thinks my IDE,will be of great help,no hot hands,no need of speed ,no need of labourious work as a minor,just let it done.