News:

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

Main Menu

Using Vasily's runtime comparison operators.

Started by hutch--, January 20, 2017, 03:20:10 AM

Previous topic - Next topic

hutch--

I have heard some noise here and there about the lack of native runtime comparison operators in 64 bit MASM but Vasily's runtime comparison operators work just fine. They look a little different as the pre-processor in 64 bit MASM excludes <>! characters but its no big deal and you get used to them fast enough.

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

    include \masm32\include64\masm64rt.inc

    .code

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

entry_point proc

    LOCAL pMsg      ;QWORD
    LOCAL wParam    :QWORD
    LOCAL lParam    :QWORD

    mov wParam, 1
    mov pMsg, WM_PAINT
    mov lParam, 2

    .if wParam == 1
      .if lParam {} 3 || pMsg {} WM_COMMAND
        .if wParam } 1 || wParam { 4
          conout "  ----------------------------------------",lf
          conout "  Ain't Vasily's runtime comparisons great",lf
          conout "  ----------------------------------------",lf
        .endif
      .endif
    .endif

    waitkey

    .exit

    ;;; invoke ExitProcess,0

    ret

entry_point endp

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

ragdog

Quoteno big deal and you get used to them fast enough.

Sure!. But is not a good idea, Cpp/Masm32 or other languages use "<>!"

Regards,

hutch--

 :biggrin:

Trouble is assembler uses CMP / Jxx natively so its a matter of who cares about C/C++ notation.

mabdelouahab

#3
hutch, try Mabdelouahab's runtime comparison operators, It's the best.  :biggrin:

hutch--

I have had a look at your file and it looks like you have done some interesting stuff but there is no documentation or examples of how the macros work so I don't know what they do.

mabdelouahab

Quote from: hutch-- on January 20, 2017, 06:55:56 PM
I have had a look at your file and it looks like you have done some interesting stuff but there is no documentation or examples of how the macros work so I don't know what they do.

Comparison run-time operators:
     ==            Equal
     {}            Not equal
     }             Greater than
     }=            Greater than or equal to
     {             Less than
     {=            Less than or equal to
     ~             Logical NOT
     &&            Logical AND
     ||            Logical OR
     CARRY?        Carry bit set
     OVERFLOW?     Overflow bit set
     PARITY?       Parity bit set
     SIGN?         Sign bit set
     ZERO?         Zero bit set



Example:

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

    include \masm32\include64\masm64rt.inc
    include X64.inc

    .code

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

entry_point proc

    LOCAL pMsg      ;QWORD
    LOCAL wParam    :QWORD
    LOCAL lParam    :QWORD

    mov wParam, 1
    mov pMsg, WM_PAINT
    mov lParam, 2

    .if wParam == 1
      .if lParam {} 3 || pMsg {} WM_COMMAND
        .if wParam } 1 || wParam { 4
          conout "  ----------------------------------------",lf
          conout "  Ain't Mabdelouahab's runtime comparisons great",lf
          conout "  ----------------------------------------",lf
        .endif
      .endif
    .endif

    waitkey

    invoke ExitProcess,0

    ret

entry_point endp

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


hutch--

 :t

I notice you have used the same set of symbols as Vasily did.

I wonder if the symbols can be changed to characters as in the following table.

  ; ************************************************

    run_time_comparisons MACRO
      % echo     **************************************
      % echo     variable run time comparison operators
      % echo     **************************************
      % echo     -------------
      % echo     equality test
      % echo     -------------
      % echo     eq equal
      % echo     ne not equal
      % echo    
      % echo     -----------------
      % echo     signed comparison
      % echo     -----------------
      % echo     gt signed greater than
      % echo     lt signed less than
      % echo     ge signed greater than or equal
      % echo     le signed less than or equal
      % echo    
      % echo     -------------------
      % echo     unsigned comparison
      % echo     -------------------
      % echo     ua unsigned above
      % echo     ub unsigned below
      % echo     ae unsigned above or equal
      % echo     be unsigned below or equal
      % echo     **************************************
    ENDM

  ; **********************************************

ragdog

Hello

I understand writing Macros a little, but i have try to change the characters  "{}" to other i got many error´s.  :(

L_ComparOperation     INSTR 1,<ConditionsStr>,<{}>

is this a fixed character set ?

Greets,

hutch--

I think the problem is the sheer complexity of a runtime comparison system written using MASM macros which is not the most gracious method of constructing such a capacity but sad to say its all there is. I have done extensive testing on Vasily's system and it is reliable and from what I can tell without doing a range of testing, the version by mabdelouahab looks like it will also work OK. It is certainly a lot easier to read than Vasily's version.

From having looked at both reasonably closely, neither would be all that easy to modify unless you know exactly what all of it means and as neither version has any explanation or viable documentation so I think it would be the author who would need to modify the system to ensure it works correctly.