News:

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

Main Menu

[SSE2]Make all bytes positive

Started by Farabi, December 21, 2012, 07:58:19 PM

Previous topic - Next topic

Farabi

Im substracting 16 8bit integer and want to have the result all positive. How to do that?
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

jj2007

Something like this?

.code
whatever   db 123, -127, 99, 255, 128, 127, 0, 100, 123, -127, 99, 255, 128, 127, 0, 100
start:
   mov eax, 7f7f7f7fh
   movd xmm1, eax
   pshufd xmm1, xmm1, 0
   movups xmm0, oword ptr whatever
   andps xmm0, xmm1

Farabi

Quote from: jj2007 on December 21, 2012, 08:26:06 PM
Something like this?

.code
whatever   db 123, -127, 99, 255, 128, 127, 0, 100, 123, -127, 99, 255, 128, 127, 0, 100
start:
   mov eax, 7f7f7f7fh
   movd xmm1, eax
   pshufd xmm1, xmm1, 0
   movups xmm0, oword ptr whatever
   pandn xmm0, xmm1


:t Well I dont get it how it work yet, but yes that is what I want. I though there are a single instruction out there but that should sufficient, thanks.
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

jj2007

It seems andps is the one to choose, not pandn - see corrected code above.

Farabi

Can I know what this code does?

pshufd xmm1, xmm1, 0

It doesnot seems did nothing.
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

qWord

Farabi, do you want to have the absolute value of the difference? (abs(b-a))
MREAL macros - when you need floating point arithmetic while assembling!

jj2007

Quote from: Farabi on December 21, 2012, 08:52:09 PM
Can I know what this code does?

pshufd xmm1, xmm1, 0

It doesnot seems did nothing.

It propagates the lowest dword to the other three dwords of the xmm reg, so that xmm1 contains
7f7f7f7f7f7f7f7f7f7f7f7f7f7f7fh

Farabi

Quote from: qWord on December 21, 2012, 09:07:03 PM
Farabi, do you want to have the absolute value of the difference? (abs(b-a))

I think integer will always be absolute.
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

jj2007

Quote from: Farabi on December 22, 2012, 03:48:19 AM
Quote from: qWord on December 21, 2012, 09:07:03 PM
Farabi, do you want to have the absolute value of the difference? (abs(b-a))

I think integer will always be absolute.

That doesn't answer the question, Onan. Can you post a real example what you want to see?

Farabi

Quote from: jj2007 on December 22, 2012, 04:08:20 AM
Quote from: Farabi on December 22, 2012, 03:48:19 AM
Quote from: qWord on December 21, 2012, 09:07:03 PM
Farabi, do you want to have the absolute value of the difference? (abs(b-a))

I think integer will always be absolute.

That doesn't answer the question, Onan. Can you post a real example what you want to see?

Sorry maybe Im misunderstood with the term "absolute".

I need to substract a pixel and check if the result was less than ten, and to check all of that I need all to be positive, if is it negative, I need to add another cycle to check wheter it negative or not.


mov edx,bm.bmBits
movd xmm1,[edx]
pxor xmm0,xmm0
psubb xmm0,xmm1
lea edx,buff
movd [edx],xmm0


You want me to post the whole project?
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

Farabi

http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

dedndave

perhaps it's the addressing mode ?
it's SSE2 - i figure your CPU does that
you must be using .686/.MMX/.XMM or the other instructions wouldn't work  :P

Farabi

Quote from: dedndave on December 22, 2012, 01:06:53 PM
perhaps it's the addressing mode ?
it's SSE2 - i figure your CPU does that
you must be using .686/.MMX/.XMM or the other instructions wouldn't work  :P

I can use "psubb" which is SSE2 instruction but not  "pshufd" why?
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

qWord

Quote from: Farabi on December 22, 2012, 01:21:41 PM
Quote from: dedndave on December 22, 2012, 01:06:53 PM
perhaps it's the addressing mode ?
it's SSE2 - i figure your CPU does that
you must be using .686/.MMX/.XMM or the other instructions wouldn't work  :P

I can use "psubb" which is SSE2 instruction but not  "pshufd" why?
error message?

Also remarks the instruction pcmpGTb (and pcmpEQb)
MREAL macros - when you need floating point arithmetic while assembling!

Farabi

Quote from: qWord on December 22, 2012, 01:32:43 PM
Quote from: Farabi on December 22, 2012, 01:21:41 PM
Quote from: dedndave on December 22, 2012, 01:06:53 PM
perhaps it's the addressing mode ?
it's SSE2 - i figure your CPU does that
you must be using .686/.MMX/.XMM or the other instructions wouldn't work  :P

I can use "psubb" which is SSE2 instruction but not  "pshufd" why?
error message?

Also remarks the instruction pcmpGTb (and pcmpEQb)

Here is the error message "error A2008: syntax error : xmm"
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165