The MASM Forum

Microsoft 64 bit MASM => MASM64 SDK => Topic started by: ragdog on January 13, 2017, 05:11:55 AM

Title: Ml64 If/else problem
Post by: ragdog on January 13, 2017, 05:11:55 AM
Hello all

Have the Masm64 (ml64) a problem with the If/else statement?

error A2052:forced error : Bad conditional operator.

.if (rax !=   INVALID_HANDLE_VALUE)

Greets,
Title: Re: Ml64 If/else problem
Post by: Vortex on January 13, 2017, 05:23:18 AM
Hi ragdog,

Reading \masm32\macros64\vasily.inc :

Code: [Select]
     Operator      Meaning
 
     ==            Equal
     {}            Not equal
     }             Greater than
     }=            Greater than or equal to
     {             Less than
     {=            Less than or equal to
     &             Bit test (format: expression & bitnumber)
     ~             Logical NOT
     |          Bit test
     &&            Logical AND

     ||            Logical OR

Code: [Select]
.if (rax {} INVALID_HANDLE_VALUE)
Title: Re: Ml64 If/else problem
Post by: ragdog on January 13, 2017, 05:48:15 AM
Thank you Vortex

What is this for skurril new If/else statments and Operator ?
I think i will be not a friend of Masm64 with ML64.

I love the old syntax like Masm32 .

Greets,
Title: Re: Ml64 If/else problem
Post by: Vortex on January 13, 2017, 06:28:00 AM
Hi ragdog,

Vasily had to implement those macros while creating the HLL constructs for ml64 if I am not wrong.
Title: Re: Ml64 If/else problem
Post by: ragdog on January 13, 2017, 06:37:56 AM
Correct

But i have think i can use ml64 without the extern If/else macos from Vasily

Know read i

Quote
ML64 doesn't support high level language constructs

Or Invoke macro.

Ml64 is for the Cat  :icon_eek:
Title: Re: Ml64 If/else problem
Post by: hutch-- on January 13, 2017, 09:21:21 AM
ML64 comes unconfigured and it required macros to make it usable for general purpose coding. The work I have done so far includes a stack frame macro and an invoke macro, both of which work correctly. The runtime comparison code that Vasily wrote had to substitute "{" for "<" and "}" for ">" because ML64 does not allow the use of < > in macro code. I have been using Vasily's runtime comparison code for some time now and it all works fine.

In the MACRO file that is done so far, the .switch macro originally written by Greg Falen works fine. Have a look at the most recent help file I have posted for the details of how the stack frame and invoke work.
Title: Re: Ml64 If/else problem
Post by: ragdog on January 13, 2017, 08:32:59 PM
Hello Hutch

Yes it works your Masm64 with macros,but i use in Masm32 the  HLL constructs (Operator)

I'm not a friend of .switch macro

Ok ml64 support not the HLL constructs but is not usefull to change the Vasily Macros to the old Operator?
like

Code: [Select]
! ,!= ,& ,&& ,< ,<= ,== ,> ,>= ,|| etc.

To use a brace  ({} Not equal) is not useful.

Following situation:

I have a cpp source or Masm32 all use "! ,!= ,& ,&& ,< ,<= ,== ,> ,>= ,||   etc."
Now i port  this code to Masmx64 ,i must change many code and operator this is not useful.

But I think you know it best.

Regards,
Title: Re: Ml64 If/else problem
Post by: jj2007 on January 13, 2017, 09:07:57 PM
To use a brace  ({} Not equal) is not useful.

Try a google images search for ugly braces (warning, not for the faint of heart!)
Title: Re: Ml64 If/else problem
Post by: hutch-- on January 14, 2017, 05:47:32 AM
ragdog,

The problem is this, Microsoft do not provide any high level support and 64 bit MASM comes unconfigured but it has a near identical pre-processor which allow much of the high level operators to be emulated in a similar form to the old 32 bit version. 64 bit MASM is simply not compatible with the old 32 bit version and is a lower level assembler so there is no simple porting available. Without the endless prototyping and notation restrictions it is simpler and faster to use but it comes with a few restrictions of its own, one is that the angle brackets < > are treated as notation for structures in the .data .data? sections which excludes them as operators for writing macros.

With the work I have done with 64 bit MASM, it has allowed me to change bits and pieces, fix odd problems here and there which I have not been able to do in the 32 bit version as you don't change a system and break anyone's code that has used it. As far as the curly braces, if you want to use 64 bit MASM and don't want to use them, do your comparisons with normal mnemonics.

You can look at alternative assemblers, FASM is known to be reliable, for Linux GAS is a good tool, JWASM has the notation you want but is a dead project or you can try the Watcom forks of JWASM as they are being developed. POASM is well written and has the support of a very good tool set but very little backup as Pelle is mainly interested in his C compiler and tools.
Title: Re: Ml64 If/else problem
Post by: ragdog on January 14, 2017, 06:31:34 AM
Yes i know Hutch

I test the last days alternative assemblers HJwasm,Posasm, and now Ml64
to find the optimal x64 assembler for me.


Title: Re: Ml64 If/else problem
Post by: hutch-- on January 16, 2017, 03:10:51 AM
Here is a small example of Vasily's alternate run time comparison operators.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include64\masm64rt.inc

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    LOCAL var   :QWORD

    mov var, 0

    .if var == 1
      conout "var = 1",lf
    .elseif var } 2
      conout "var is greater than 2",lf
    .else
      conout "Nope, I dunno",lf
    .endif

    .if var { 1 || var } -1
      conout "eureka",lf
    .endif

    waitkey

    invoke ExitProcess,0

    ret

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end


Here is an expanded version.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include64\masm64rt.inc

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    LOCAL var   :QWORD

    mov var, 0

  ; --------
  ; IF block
  ; --------
    .if var == 1
      conout "var = 1",lf
    .elseif var } 2
      conout "var is greater than 2",lf
    .else
      conout "Nope, I dunno",lf
    .endif

    .if var { 1 || var } -1
      conout "eureka",lf
    .endif

  ; ------------
  ; switch block
  ; ------------
    .switch var
      .case 0
        conout "You selected 0",lf
      .case 1
        conout "You selected 1",lf
      .case 2
        conout "You selected 2",lf
      .case 3
        conout "You selected 3",lf
      .case 4
        conout "You selected 4",lf
      .case 5
        conout "You selected 5",lf
    .endsw

    waitkey "Loop code, press any key ...."

  ; ---------
  ; loop code
  ; ---------
    mov var, 100

  lpst:
    conout str$(var),lf
    sub var, 1
    jump lpst WHILE var GT 0

    waitkey

    invoke ExitProcess,0

    ret

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end
Title: Re: Ml64 If/else problem
Post by: TouEnMasm on July 14, 2020, 03:16:42 PM

Is it not possible to modify the Vasily.inc to change {} in != and so on.
Title: Re: Ml64 If/else problem
Post by: hutch-- on July 14, 2020, 04:47:35 PM
Vasily's notation also supports an alternative, the second using the logic notation tilde. "~".

    {}             Not equal
    ~=             Not equal        (alternative)

For people who cannot read Vasily's notation. This is a higher level notation that can do memory to memory comparisons.

  HIGH LEVEL .If BLOCK

    .If condition
      ; your code

    .ElseIf condition
      ; your code

    .ElseIf condition
      ; your code

    .Else
      ; your code

    .EndIf

  COMPARISON RUN TIME OPERATORS

    eq      equals
    ne      not equal
    ge      greater than or equal
    gt      greater than
    le      less than or equal
    lt      less than

    The run time operators are the same as the familiar notation used by the MASM pre-processor.
Title: Re: Ml64 If/else problem
Post by: TouEnMasm on July 14, 2020, 06:47:20 PM
 :thumbsup:
but need the sample,the BNF grammar say:
Quote
controlIf
    .IF     cExpr ;;
    directiveList
    ⟦ controlElseif ⟧
    ⟦ .ELSE ;;
    [directiveList⟧
    .ENDIF ;;
the search cExpr give:
Quote
cExpr
    aExpr | cExpr || aExpr


and the compiler say "error syntax"



Title: Re: Ml64 If/else problem
Post by: hutch-- on July 14, 2020, 08:24:31 PM
I have seen this stuff before but Microsoft data for MASM mixes 16, 32 and 64 bit and most of it is not compatible with each other version. I use the 64 bit version completely independently from the old ML.EXE 16 and 32 bit versions and most of its capacity has had to be determined empirically as the documentation is appalling.

RE: The original topic, the 64 bit version does not support the 32 bit version .IF notation so I have used Vasily's version with some wrappers around it. With enough practice the pre-processor in 64 bit MASM can get most things done but its a bit tedious and badly documented as usual.
Title: Re: Ml64 If/else problem
Post by: TouEnMasm on July 14, 2020, 10:25:26 PM
" bit tedious and badly documented as usual."
I agree with that  :toothy:.
As the subject is ML64 bits,I was speaking about ML64.exe .
Too bad,another hope who fall.
Stay,a modify of vasily.inc,must be possible.
Title: Re: Ml64 If/else problem
Post by: TouEnMasm on July 14, 2020, 11:29:17 PM
 :icon_idea:
I modify the vasily.inc so now,he recognize != instead of {}
I have put ECHO to follow the macro path.
I have made two modifies with two comments ;------ToutEnMasm modify -----
You don't need any more include to make it run,ML64 is enough.It's the minimal version that I have always posted + vasily.inc.

---------------------------------------------- LATER ------------------------------------------------------------------
don't work,made an error on }
Bad news,I had no see that the char ! and < aren't view by the ECHO,ALL is lost,must stay as it is,it is better