SSE2: pand xmm3, 31?
-
- Posts: 2852
- Joined: Jan 02, 2017 0:34
- Location: UK
SSE2: pand xmm3, 31?
SSE2 is very nearly an immediate free zone - what a pain.
This is what I would like to do 'pand xmm3, 31' but I am getting 'operand type mismatch for pand'.
I have been at this for a while. Is there a workaround?
This is what I would like to do 'pand xmm3, 31' but I am getting 'operand type mismatch for pand'.
I have been at this for a while. Is there a workaround?
Re: SSE2: pand xmm3, 31?
hello deltarho[1859]
I think you need to move the integer 31 into another xmm register and work with that
I think you need to move the integer 31 into another xmm register and work with that
-
- Posts: 2852
- Joined: Jan 02, 2017 0:34
- Location: UK
Re: SSE2: pand xmm3, 31?
@srvaldez
I would love to but we cannot move an immediate into a xmm register. We can use immediates with the shift instructions but very little else that I can see. I have even tried moving an immediate into a x86 and moving that but I cannot get that to work.
I would love to but we cannot move an immediate into a xmm register. We can use immediates with the shift instructions but very little else that I can see. I have even tried moving an immediate into a x86 and moving that but I cannot get that to work.
Re: SSE2: pand xmm3, 31?
I am no expert, but I think you need to move from memory
Code: Select all
dim as longint m=123456789, n=31,r
asm
movq xmm2,[n]
movq xmm3,[m]
pand xmm3, xmm2
movq [r],xmm3
end asm
? r,m and n
sleep
-
- Posts: 2852
- Joined: Jan 02, 2017 0:34
- Location: UK
Re: SSE2: pand xmm3, 31?
@srvaldez
Yep, that does it. <smile>
I am off topic now but I now need to negate a register.
I have tried this:
pcmpeqd xmm3, xmm3 ' fill xmm3 with 1s
pxor xmm3, xmm2 ' I want xmm3 to be equal to -xmm2
With x86 we have opcodes to do these things. <grrrr>
Yep, that does it. <smile>
I am off topic now but I now need to negate a register.
I have tried this:
pcmpeqd xmm3, xmm3 ' fill xmm3 with 1s
pxor xmm3, xmm2 ' I want xmm3 to be equal to -xmm2
With x86 we have opcodes to do these things. <grrrr>
-
- Posts: 2852
- Joined: Jan 02, 2017 0:34
- Location: UK
Re: SSE2: pand xmm3, 31?
We need to use memory here as well
Not quite there - I am getting -51.
With x86 we just use NEG.
I will keep at it.
Code: Select all
Dim As Longint TempVar = 50
Asm
pcmpeqd xmm1, xmm1 ' fill xmm3 with 1s
movq xmm0, [TempVar]
pxor xmm1, xmm0
movq [TempVar], xmm1
End Asm
Print TempVar
Sleep
Not quite there - I am getting -51.
With x86 we just use NEG.
I will keep at it.
Re: SSE2: pand xmm3, 31?
you could do this
or this
Code: Select all
dim as longint m=50, r=&hffffffffffffffffLL
asm
movd xmm2,[r]
movq xmm3,[m]
pandn xmm3, xmm2
movq [r],xmm3
end asm
? r,not m
or this
Code: Select all
dim as longint m=50, r
asm
pcmpeqd xmm2, xmm2
movq xmm3,[m]
pandn xmm3, xmm2
movq [r],xmm3
end asm
? r,not m
-
- Posts: 2852
- Joined: Jan 02, 2017 0:34
- Location: UK
Re: SSE2: pand xmm3, 31?
I am getting -51 with both of them.
Re: SSE2: pand xmm3, 31?
deltarho[1859] wrote:I am getting -51 with both of them.
yes, but that's the same result as the FB integer NOT
-
- Posts: 2852
- Joined: Jan 02, 2017 0:34
- Location: UK
Re: SSE2: pand xmm3, 31?
I am looking for negate ie 50 becomes -50.
This gives -50
The problem with these workarounds to do something which we can do with just one instruction in x86 is that it slows things down to the point where it isn't worth it. <laugh>
This gives -50
Code: Select all
dim as longint m=50, r, one = 1
asm
pcmpeqd xmm2, xmm2
movq xmm3,[m]
pandn xmm3, xmm2
movq xmm4, [one]
paddq xmm3, xmm4
movq [r],xmm3
end asm
? r
sleep
The problem with these workarounds to do something which we can do with just one instruction in x86 is that it slows things down to the point where it isn't worth it. <laugh>
Re: SSE2: pand xmm3, 31?
Take deb as pseudocode for print eax:Note you can do this simple negation for 4 DWORDs.
Code: Select all
movups xmm1, OWORD PTR MyO ; DWORD 1000, 2000, ...
xorps xmm0, xmm0 ' set to zero
psubd xmm0, xmm1
movd eax, xmm0
deb 4, "A", eax
pshufd xmm0, xmm0, 11100001b
movd eax, xmm0
deb 4, "B", eax
Re: SSE2: pand xmm3, 31?
try this, only 32-bits
Code: Select all
dim as long m=50, r
asm
pcmpeqd xmm2, xmm2
movd xmm3,[m]
psignd xmm3,xmm2
movd [r],xmm3
end asm
? r,(not m)+1
Re: SSE2: pand xmm3, 31?
Nice, srvaldez. I had not used PSIGND before, it works fine but is somewhat slower than PSUBD in my tests.
-
- Posts: 2852
- Joined: Jan 02, 2017 0:34
- Location: UK
Re: SSE2: pand xmm3, 31?
Thanks srvaldez - that did it.
I couldn't find psignd in my SSE2 Instruction Set. Looks like it came in with SSE3. I need to look into that - I cannot use something which other folks may not have.
Anyway, the code that I am working on sees the console open and then closes. I hate that - give me a GPF any day. <smile>
Nope: SSSE3 - oh, dear!
I couldn't find psignd in my SSE2 Instruction Set. Looks like it came in with SSE3. I need to look into that - I cannot use something which other folks may not have.
Anyway, the code that I am working on sees the console open and then closes. I hate that - give me a GPF any day. <smile>
Nope: SSSE3 - oh, dear!
Re: SSE2: pand xmm3, 31?
You can use psubd, see above, it's SSE2.deltarho[1859] wrote:Nope: SSSE3 - oh, dear!
Who is online
Users browsing this forum: No registered users and 9 guests