The MASM Forum Archive 2004 to 2012
Welcome, Guest. Please login or register.
October 01, 2020, 03:23:28 PM

Login with username, password and session length
Search:     Advanced search
128553 Posts in 15254 Topics by 684 Members
Latest Member: mottt
* Home Help Search Login Register
+  The MASM Forum Archive 2004 to 2012
|-+  General Forums
| |-+  The Laboratory (Moderator: Mark_Larson)
| | |-+  PSHUFB test piece.
« previous next »
Pages: [1] Print
Author Topic: PSHUFB test piece.  (Read 6080 times)
hutch--
Administrator
Member
*****
Posts: 12013


Mnemonic Driven API Grinder


PSHUFB test piece.
« on: January 27, 2011, 04:01:54 AM »

Needed to see the capacity of BSHUFB. Looks like it will really hurry up BSWAP for streaming data. It appears to be a very useful instruction with many applications. NOTE that it requires SSE3.

Code:
IF 0  ; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
                      Build this template with "CONSOLE ASSEMBLE AND LINK"
                                 Computer must be SSE3 capable
ENDIF ; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい

    include \masm32\include\masm32rt.inc

    .data
      align 16
      shflmask dd  03020100h,07060504h,0B0A0908h,0F0E0D0Ch
      pshmsk dd shflmask

      align 16
      shflmask2 dd 00010203h,04050607h,08090A0Bh,0C0D0E0Fh
      pshmsk2 dd shflmask2

      align 16
      mytest db "32107654BA98FECD",0,0,0,0      ; data to shuffle
      pmtst dd mytest

      align 16
      mybuff db 20 dup (0)                      ; output buffer for result
      pmbuf dd mybuff

    .code

start:
   
; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい

    call main
    inkey
    exit

; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい

main proc

    mov eax, pshmsk2            ; load the shuffle mask address
    movdqa xmm2, [eax]          ; copy it into XMM2

    mov eax, pmtst              ; load the data address in EAX
    movdqa xmm1, [eax]          ; load the data into XMM1

    pshufb xmm1, xmm2           ; shuffle bytes to order in XMM2

    mov eax, pmbuf              ; load output buffer address
    movdqa [eax], xmm1          ; copy 16 byte result to it

    print pmbuf,13,10

    ret

main endp

; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい

end start
Logged

Regards,



Download site for MASM32
http://www.masm32.com
GregL
Member
*****
Gender: Male
Posts: 1897



Re: PSHUFB test piece.
« Reply #1 on: January 30, 2011, 03:50:15 AM »

hutch,

I had to add .XMM to get it to assemble with MASM 10.0.

Logged
hutch--
Administrator
Member
*****
Posts: 12013


Mnemonic Driven API Grinder


Re: PSHUFB test piece.
« Reply #2 on: January 30, 2011, 03:54:13 AM »

That makes sense, I built this with ML version 9.0 and just typed it in and it worked.
Logged

Regards,



Download site for MASM32
http://www.masm32.com
sinsi
Member
*****
Gender: Male
Posts: 1758


RIP Bodie 1999-2011


Re: PSHUFB test piece.
« Reply #3 on: January 30, 2011, 06:41:35 AM »

My new you beaut AMD processor doesn't support SSSE3 so I get an invalid opcode errorfor pshufb Sad
Logged

Light travels faster than sound, that's why some people seem bright until you hear them.
hutch--
Administrator
Member
*****
Posts: 12013


Mnemonic Driven API Grinder


Re: PSHUFB test piece.
« Reply #4 on: January 30, 2011, 08:05:38 AM »

What a shame, is there another AMD specific that will do the same or similar task ?
Logged

Regards,



Download site for MASM32
http://www.masm32.com
sinsi
Member
*****
Gender: Male
Posts: 1758


RIP Bodie 1999-2011


Re: PSHUFB test piece.
« Reply #5 on: January 30, 2011, 08:22:16 AM »

Maybe in SSE5? It seems that Intel and AMD are going their own ways again.

This was interesting: http://abinstein.blogspot.com/2007/09/amds-latest-x86-extension-sse5-part-2.html
AMD make logical instruction encodings to allow for expansion whereas Intel squeeze them in any old how lol
Logged

Light travels faster than sound, that's why some people seem bright until you hear them.
frktons
Member
*****
Gender: Male
Posts: 1048



Re: PSHUFB test piece.
« Reply #6 on: January 31, 2011, 05:45:44 PM »

It works fine.  BigGrin
Logged

Mind is like a parachute. You know what to do in order to use it :-)
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP The MASM Forum Archive 2004 to 2012 | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!