warning on SHR and masm 8,9,10

Started by qWord, June 12, 2009, 11:29:34 AM

Previous topic - Next topic

qWord

hi,

I've discovered that masm (8,9,10) doesn't like negative values (values declared using '-': -1,-2,-3 ...) for shifting with SHR.
If the value was declared using negative sign ('-'), the result is always -1 (0ffffffffh):

; this works with all masm versions
test_value = 0ffffffffh
%echo @CatStr(%(test_value SHR 31))

; wrong result with masm 8,9,10 ,correct with 6 and 7
test_value = -1
%echo @CatStr(%(test_value SHR 31))

; the same with other value
test_value = -123
%echo @CatStr(%(test_value SHR 16))

Is this a known bug?

regards, qWord
FPU in a trice: SmplMath
It's that simple!

ToutEnMasm


Not bug .If SHL and SHR exist,it's not to have negative value.Number of shift (32 bits) go threw 31 to 0.Masm can do nothing best.

qWord

hi ToutEnMasm ,

Did you mean that SHR should behaves like sar (Shift Arithmetic Right)? -That make no sens to me.
Also: Masm Version 6 and 7 returns the correct value (IMHO)  while Version 8,9 and 10 allways return -1.

EDIT:
I've figured out:

-12345678 SHR 16   ; or (-12345678) SHR 16
is interpreted as:
NOT(12345678 SHR 16)


regards,
qWord
FPU in a trice: SmplMath
It's that simple!

Mark Jones

Add yet another layer of abstraction... ::)

How much more can we take, before programming becomes too abstract, too difficult? Already, staying "on top" of this ship is proving difficult, as each ship sinks and is replaced by the next...  </soapbox>
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

ToutEnMasm


I have misanderstood what you are saying. I believe that you want to make a negative shift  .
Here is some tests who explain where is the problem.
Quote
.const
bugtest equ -12345678 SHR 16
.code
start:
   mov eax,-12345678     ;0FF439EB2h correct
   shr eax,16                  ;correct result 0FF43H
   mov ecx,bugtest ;shift.asm(125) : error A2022:instruction operands must be the same size

Make your try without macro.
The generated error seem to be a change in the type of constant
The macro can outpass this problem and made one error.