The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Jeff on May 17, 2005, 06:05:49 AM

Title: unexpected results from EQ operator
Post by: Jeff on May 17, 2005, 06:05:49 AM
hey guys,
i cant really figure out what's causing the problem.  im writing up little macro functions that "simplify" the use of the OPATTR operator for me.  however, the way i have it, it always generates false and now im totally stuck.  did i do something wrong or overlook something?

this is my testing code:
.386
.MODEL FLAT,STDCALL

ISDATA MACRO symbol:REQ
    IFNB <symbol>
        IF OPATTR symbol EQ 2Ah
            EXITM <-1>
        ELSE
            EXITM <0>
        ENDIF
    ENDIF
ENDM

ISSTACK MACRO symbol:REQ
    IFNB <symbol>
        IF OPATTR symbol EQ 62h
            EXITM <-1>
        ELSE
            EXITM <0>
        ENDIF
    ENDIF
ENDM

ExitProcess PROTO :DWORD

.DATA
a1 DWORD ?

.CODE
main PROC
LOCAL a2:DWORD
    MOV eax,ISDATA(a1)
    MOV ebx,ISDATA(a2)
    MOV ecx,ISSTACK(a1)
    MOV edx,ISSTACK(a2)
    MOV eax,OPATTR a1
    MOV ebx,OPATTR a2
    MOV ecx,OPATTR a1
    MOV edx,OPATTR a2
    MOV eax,(OPATTR a1 EQ 2Ah)
    MOV ebx,(OPATTR a2 EQ 2Ah)
    MOV ecx,(OPATTR a1 EQ 62h)
    MOV edx,(OPATTR a2 EQ 62h)
    INVOKE ExitProcess,0
main ENDP
END main


your help would be greatly appreciated.
Title: Re: unexpected results from EQ operator
Post by: MichaelW on May 17, 2005, 07:14:03 AM
Hi Jeff,

Try putting parentheses around "OPATTR symbol" so MASM will compare the return value for OPATTR to 2Ah, instead of comparing the symbol to 2Ah.
Title: Re: unexpected results from EQ operator
Post by: Jeff on May 17, 2005, 08:00:44 AM
oh that was it, thanks michael.  i was doing this thinking that OPATTR had higher precedence than EQ.  gotta slap myself for that... ow.  :)