News:

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

Main Menu

Probable Bug related to opattr

Started by Biterider, November 02, 2020, 02:17:53 AM

Previous topic - Next topic

Biterider

Hi
I encountered strange behavior while evaluating an expression.
I've compared it to the ML output and while it's different I think it's probably wrong too.  :sad:
The whole thing is related to the syntax opattr(xxx) vs (opattr xxx).
Attached is the test code.

Regards, Biterider

TouEnMasm


Sorry but what is wrong ??   ,perhaps the copy of the wrong line could help ?

Fa is a musical note to play with CL

Biterider

Hi
The test code evaluates 3 different syntaxes:

  Result = OAT_REGISTER and opattr(eax)
  Result = opattr(eax) and OAT_REGISTER
  Result = (opattr eax) and OAT_REGISTER


and returns the result to a log file.
This is done from a batch file that compiles the same asm file for ML and UASM one after the other.
If you look at the contents of the log file you can see that both assembers do not return the same values and are acting a little strange for the 3 syntaxes.

I hope it's a little more understandable now.

Regards, Biterider


jj2007

I always use oa=opattr(arg) and 127 to mask out the external label and language bits. Using and 127 the 810 becomes 42, as shown in the image. Attached a batch file that creates two log files configured for Alt Tab switching.

;     Bit       Set If...
;     0         References a code label
;     1         Is a memory expression or has a relocatable data label
;     2         Is an immediate expression
;     3         Uses direct memory addressing, i.e. is an absolute memory reference
;     4         Is a register expression
;     5         References no undefined symbols and is without error
;     6         References a stack location (usually a LOCAL variable or parameter)
;     7         References an external label
;     8-10      Language type (0=no type)
               ; 76543210      ; use and 127 to mask external label and language bits
atMemory        = 34            ;
00100010      ; [edx+20], [ebx+20], [eax+edx+20], JWasm: [eax+4*eax+20], [eax+20]
atImmediate     = 36            ;
00100100
atLabel         = 37            ;
10100101
atOffset        = 38            ;
10100110      ; offset CrLf$ (immediate and mem expression)
atGlobal        = 42            ;
10101010      ; CrLf$, Masm: [eax+4*eax+20], [eax+20]
atRegLabel      = 43            ;
10101011      ; Masm: [eax+start] (Jwasm yields 37)
atRegister      = 48            ;
00110000      ; also xmm
atLocal         = 98            ; 01100010

Biterider

Hi JJ
Thank you for your feedback.
As you can see from your evaluation, the values are not the same between assemblers.
Your code lacks the AND operation, which produces different results when you change the order of the operands but only in combination with opattr.
The use of immediate values and their permutations produces the same result (direct test).

  Result = OAT_REGISTER and opattr(xxx)
  Result = opattr(xxx) and OAT_REGISTER


At the moment, the only safe syntax seems to be
Result = (opattr xxx) and OAT_REGISTER

For more clarity I build a table showing the results

Biterider


_japheth

The OPATTR operator has a very low precedence, lower than AND, that's why "opattr x and y" may give unexpected results.
Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

HSE

Quote from: _japheth on November 02, 2020, 06:20:01 PM
The OPATTR operator has a very low precedence, lower than AND, that's why "opattr x and y" may give unexpected results.
Fantastic!

I was forgotten why I use double parenthesis  :biggrin::
    IF (OPATTR(tk_dest)) and 00010000y ;; register
         tk_op3 tk_dest , tk_exp
    ELSEIF (OPATTR(tk_dest)) and 00000100y ;; inmediate
        .err A2052 invalid bit operation on inmediate
    ELSE
Equations in Assembly: SmplMath

Biterider


Hi Japheth
Thanks for the clarification.
Now the results make sense again.

Biterider