Author Topic: Ml64 If/else problem  (Read 2205 times)

ragdog

  • Member
  • ****
  • Posts: 572
Ml64 If/else problem
« 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,

Vortex

  • Member
  • *****
  • Posts: 1775
Re: Ml64 If/else problem
« Reply #1 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)

ragdog

  • Member
  • ****
  • Posts: 572
Re: Ml64 If/else problem
« Reply #2 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,

Vortex

  • Member
  • *****
  • Posts: 1775
Re: Ml64 If/else problem
« Reply #3 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.

ragdog

  • Member
  • ****
  • Posts: 572
Re: Ml64 If/else problem
« Reply #4 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:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5271
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Ml64 If/else problem
« Reply #5 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

ragdog

  • Member
  • ****
  • Posts: 572
Re: Ml64 If/else problem
« Reply #6 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,

jj2007

  • Member
  • *****
  • Posts: 8243
  • Assembler is fun ;-)
    • MasmBasic
Re: Ml64 If/else problem
« Reply #7 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!)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5271
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Ml64 If/else problem
« Reply #8 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

ragdog

  • Member
  • ****
  • Posts: 572
Re: Ml64 If/else problem
« Reply #9 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.



hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5271
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Ml64 If/else problem
« Reply #10 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
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin: