shufps is hard to find the right immediate byte you want, so I am making a helper program
but immediate byte = I need to selfmodify it to find the right
this for starters is a snippet that makes it possible to singlestep to understand SHUFPS better
.data
ALIGN 16
tstf REAL4 1.0,2.0,3.0,4.0
tstf2 REAL4 21.0,22.0,23.0,24.0
tstf3 REAL4 1.0,2.0,3.0,4.0
tstf4 REAL4 21.0,22.0,23.0,24.0
.code
@@l1: finit
DB 0F0H ;anything that causes protection fault and start your debugger to singlestep this
NOP
MOVAPS XMM4,[tstf3]
MOVAPS XMM5,[tstf4]
imb: SHUFPS XMM4,XMM5,255
MOVAPS [tstf],XMM4
MOVAPS [tstf2],XMM5
fld tstf ;view result in debugger in fp regs, if it doesnt support showing .xmm
fld tstf+4
fld tstf+8
fld tstf+12
fld tstf2
fld tstf2+4
fld tstf2+8
fld tstf2+12
lea ebx,[imb+3] ;cant make this work
dec BYTE PTR [ebx]
jne @@l1
I searched the old forum for how to make .code segment writable, but couldnt find anything
dec causes a violation access
could appreciate some help
Good to see someone doing some sample code. :) However as a bit of constructive criticism, you should use a hex or binary value for the immediate when using SHUFPS. I usuallyuse binary because it makes it very easy to understand, since it specifies which dword in binary to use from the destination and source.
;for the purposes of the comments, all "Dwords" are 0 based. So dword 0 is the first one. dword 1 is the second, and so on.
shufps xmm0,xmm1,01010101b ;blast dword 1 of destination to first 2 dwords in destination, blast dword 1 of source to last 2 dwords in destination