Author Topic: Using Vasily's runtime comparison operators.  (Read 1101 times)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4814
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Using Vasily's runtime comparison operators.
« on: January 20, 2017, 03:20:10 AM »
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

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

ragdog

  • Member
  • ****
  • Posts: 515
Re: Using Vasily's runtime comparison operators.
« Reply #1 on: January 20, 2017, 05:00:41 AM »
Quote
no 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--

  • Administrator
  • Member
  • ******
  • Posts: 4814
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Using Vasily's runtime comparison operators.
« Reply #2 on: January 20, 2017, 11:11:42 AM »
 :biggrin:

Trouble is assembler uses CMP / Jxx natively so its a matter of who cares about C/C++ notation.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

mabdelouahab

  • Member
  • ***
  • Posts: 336
Re: Using Vasily's runtime comparison operators.
« Reply #3 on: January 20, 2017, 06:21:29 PM »
hutch, try Mabdelouahab's runtime comparison operators, It's the best.  :biggrin:
« Last Edit: January 20, 2017, 07:52:25 PM by mabdelouahab »

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4814
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Using Vasily's runtime comparison operators.
« Reply #4 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

mabdelouahab

  • Member
  • ***
  • Posts: 336
Re: Using Vasily's runtime comparison operators.
« Reply #5 on: January 20, 2017, 07:51:52 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--

  • Administrator
  • Member
  • ******
  • Posts: 4814
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Using Vasily's runtime comparison operators.
« Reply #6 on: January 20, 2017, 08:08:26 PM »
 :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

  ; **********************************************
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

ragdog

  • Member
  • ****
  • Posts: 515
Re: Using Vasily's runtime comparison operators.
« Reply #7 on: January 21, 2017, 06:13:23 AM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 4814
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Using Vasily's runtime comparison operators.
« Reply #8 on: January 21, 2017, 11:13:31 PM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

ragdog

  • Member
  • ****
  • Posts: 515
Re: Using Vasily's runtime comparison operators.
« Reply #9 on: January 22, 2017, 03:11:15 AM »
Correct