I'm trying to execute this instruction using inline assembly in
VS.NET 2002:

pshufb xmm0, xmm1

Unfortunately, pshufb is somewhat new, so VS.NET 2002 doesn't
recognize it. Is there a feasible workaround?

Re: pshufb by Carl

Carl
Thu Jul 26 22:24:11 CDT 2007

bob@coolgroups.com wrote:
> I'm trying to execute this instruction using inline assembly in
> VS.NET 2002:
>
> pshufb xmm0, xmm1
>
> Unfortunately, pshufb is somewhat new, so VS.NET 2002 doesn't
> recognize it. Is there a feasible workaround?

1. Use a newer compiler
2. use masm to build an .OBJ which you link into your project.
3. compile the instruction by hand (or with MASM) and insert the necessary
code bytes into a block of memory and then call it through a suitably
constructed function pointer. You'll need to call VirtualProtect to set the
page attributes to PAGE_EXECUTE (or similar) in order to actually run the
code in newer CPUs with the "NX bit".

-cd



Re: pshufb by bob

bob
Fri Jul 27 01:00:44 CDT 2007

On Jul 26, 8:24 pm, "Carl Daniel [VC++ MVP]"
<cpdaniel_remove_this_and_nos...@mvps.org.nospam> wrote:
> b...@coolgroups.com wrote:
> > I'm trying to execute this instruction using inline assembly in
> > VS.NET 2002:
>
> > pshufb xmm0, xmm1
>
> > Unfortunately, pshufb is somewhat new, so VS.NET 2002 doesn't
> > recognize it. Is there a feasible workaround?
>
> 1. Use a newer compiler
> 2. use masm to build an .OBJ which you link into your project.
> 3. compile the instruction by hand (or with MASM) and insert the necessary
> code bytes into a block of memory and then call it through a suitably
> constructed function pointer. You'll need to call VirtualProtect to set the
> page attributes to PAGE_EXECUTE (or similar) in order to actually run the
> code in newer CPUs with the "NX bit".
>
> -cd

I tried this:

__asm {
_emit 0x66
_emit 0x0F
_emit 0x38
_emit 0x00
_emit 0xC1
}

However, when I run it, my PC says "Illegal instruction".

Can you try it on your PC? My CPU is fairly modern, so I don't know
why it doesn't work.



Re: pshufb by Carl

Carl
Fri Jul 27 09:08:36 CDT 2007

bob@coolgroups.com wrote:
> On Jul 26, 8:24 pm, "Carl Daniel [VC++ MVP]"
> <cpdaniel_remove_this_and_nos...@mvps.org.nospam> wrote:
>> b...@coolgroups.com wrote:
>>> I'm trying to execute this instruction using inline assembly in
>>> VS.NET 2002:
>>
>>> pshufb xmm0, xmm1
>>
>>> Unfortunately, pshufb is somewhat new, so VS.NET 2002 doesn't
>>> recognize it. Is there a feasible workaround?
>>
>> 1. Use a newer compiler
>> 2. use masm to build an .OBJ which you link into your project.
>> 3. compile the instruction by hand (or with MASM) and insert the
>> necessary code bytes into a block of memory and then call it through
>> a suitably constructed function pointer. You'll need to call
>> VirtualProtect to set the page attributes to PAGE_EXECUTE (or
>> similar) in order to actually run the code in newer CPUs with the
>> "NX bit".
>>
>> -cd
>
> I tried this:
>
> __asm {
> _emit 0x66
> _emit 0x0F
> _emit 0x38
> _emit 0x00
> _emit 0xC1
> }
>
> However, when I run it, my PC says "Illegal instruction".
>
> Can you try it on your PC? My CPU is fairly modern, so I don't know
> why it doesn't work.

Mine's too old - maybe someone else can give it a shot.

-cd



When does =?UTF-8?Q?=E2=80=9C?= pshufb xmm0, xmm1 =?UTF-8?Q?=E2=80=9D?= come in handy ? by Jeff_Relf

Jeff_Relf
Sat Nov 24 20:32:59 PST 2007

When does â?? pshufb xmm0, xmm1 â?? come in handy ?


Re: When does ? pshufb xmm0, xmm1 ? come in handy ? by Tim

Tim
Sun Nov 25 19:51:00 PST 2007

Jeff?Relf <Jeff_Relf@Yahoo.COM> wrote:
>
>When does ? pshufb xmm0, xmm1 ? come in handy ?

It may be easier to think of applications if you think of it as a table
lookup in a small table.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.