News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Numeric and string equation in single IF statement

Started by key2k3, January 11, 2005, 10:25:38 AM

Previous topic - Next topic

key2k3

Hi community!

Is it possible to make an IF-statement in a macro that contains both, numerical and string expressions? My macro must check if some argument is empty and if some other, numerical arguments are in a certain range.
Until now, I could only solve it by using this code:


IFB <arg>
  temp = 1
ELSE
  temp = 0
ENDIF


But it would be much better if I could include something like <arg4> EQ <> directly into the IF statement.

Thank you very much in advance!  :U

key2k3

I wonder why this thread moved. I thought this was the forum for mixed assembler types and my question refers to MASM ... just to make it clear  ;) ... anyways, it doesn't seem like there's a coder out there who has had this problem (?!) so I took this quick workaround:


@IsBlank MACRO arg1:=<>
  IFB <arg1>
    EXITM <1>
  ENDIF
  EXITM <0>
ENDM


This can be used directly inside IF statements. Nevertheless, I still appreciate any replies on this topic.

Thanks!  :boohoo:

MichaelW

I had to run a test to be sure, but yes you can.

; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .486                       ; create 32 bit code
    .model flat, stdcall       ; 32 bit memory model
    option casemap :none       ; case sensitive

    include \masm32\include\windows.inc
    include \masm32\include\masm32.inc
    include \masm32\include\kernel32.inc
    includelib \masm32\lib\masm32.lib
    includelib \masm32\lib\kernel32.lib
    include \masm32\macros\macros.asm

    _test MACRO num, str
        IF (num GT 3) AND (@SizeStr(str) EQ 3)
          print chr$("true",13,10)
        ELSE
          print chr$("false",13,10)
        ENDIF
    ENDM

; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
    .code
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    _test 3, <abc>
    _test 4, <abcd>
    _test 4, <abc>
   
    mov   eax, input(13,10,"Press enter to exit...")
    exit
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start


I forgot to add that the above is a console app.
eschew obfuscation

key2k3

dang  ::) I forgot about SizeStr.

Thanks a bunch, MichaelW!