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 If/else problem

Started by ragdog, January 13, 2017, 05:11:55 AM

Previous topic - Next topic

ragdog

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,

Vortex

Hi ragdog,

Reading \masm32\macros64\vasily.inc :

     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


.if (rax {} INVALID_HANDLE_VALUE)

ragdog

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,

Vortex

Hi ragdog,

Vasily had to implement those macros while creating the HLL constructs for ml64 if I am not wrong.

ragdog

Correct

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

Know read i

QuoteML64 doesn't support high level language constructs

Or Invoke macro.

Ml64 is for the Cat  :icon_eek:

hutch--

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.

ragdog

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


! ,!= ,& ,&& ,< ,<= ,== ,> ,>= ,|| 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,

jj2007

Quote from: ragdog on January 13, 2017, 08:32:59 PMTo use a brace  ({} Not equal) is not useful.

Try a google images search for ugly braces (warning, not for the faint of heart!)

hutch--

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.

ragdog

Yes i know Hutch

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



hutch--

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

TouEnMasm


Is it not possible to modify the Vasily.inc to change {} in != and so on.
Fa is a musical note to play with CL

hutch--

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.

TouEnMasm

 :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"



Fa is a musical note to play with CL

hutch--

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.