Masm directives for signed comparision and other problems

Started by rufus16, December 30, 2011, 06:35:36 PM

Previous topic - Next topic

rufus16

Hello
Could someoen tell me how to change the comparision to get io worked?
I use masm.


.IF DWORD PTR[P+ECX*4] ==-1
;something

.ENDIF

P is an array with 10000 elements. I have filled  it with  -1 per byte, so it contains fffffffff. ffff  but anyway the comparision doesnt work.  COould someone tell me how to fix it?

And in native assembly, how it would look like? couldnt find anythint that would match " jump when signed and equal"

I have found one more problem, which might fix many others:



when i use something like that

DWORD PTR[P+ECX*4]

masm changes it to DWORD PTR[OFFSET P+ECX*4]
which i dont want to.

ANy idea how to fix it? ( it might fix the previous one because it was inteprpreted worng)


thanks in advanced

qWord

Overwrite the datatype with:
Quote.if SDWORD ptr ... </</<=/>= ...
.endif

When testing for equality, the singe doesn't matter.

The used jump-instructions for signed compares are:
jl/jle/jg/jge dest

For more details about conditional jumps see Intel's/AMD's documentation.
FPU in a trice: SmplMath
It's that simple!

rufus16


Then the  problem is here :

masm changes

IF DWORD PTR[P+ECX*4]

to

IF DWORD PTR[OFFSET P+ECX*4]


Do you knwo how to fix it?




jj2007

Quote from: rufus16 on December 30, 2011, 07:16:27 PM

masm changes

IF DWORD PTR[P+ECX*4]

to

IF DWORD PTR[OFFSET P+ECX*4]



How does Masm change it??
What you probably mean is that you have a variable P like this:
.data
P dd 0
... and you want the value of [P+ecx*4]
That requires dereferencing:
mov edx, P
IF DWORD PTR[edx+ECX*4]
  ...

rufus16


KeepingRealBusy

Rufus16,

Just keep reading this forum and keep asking questions when you have problems. Having a short working (whether it works correctly) code example to post along with your question also helps.

Learning is allowed here.

Dave.

dedndave

i can tell you how i would do it....

        cmp dword ptr P[4*ecx],-1
        jnz     dont_do_it


there, now wasn't that easy ?   :bg

Hobbit

Interesting, more than one way to skin a cat I guess.

Ralph