/*personal notes of renzo diomedi*/

~ 00001001 ~



IA-32 platform includes instructions for moving the new SSE2 packed double-precision floating-point data types.



Each of these instructions uses the 128-bit XMM register to move 64-bit double-precision floating-point values.
MOVAPD and MOVUPD instructions move the complete packed double-precision floating-point value into and out of the XMM registers.





# sse2float #### Gnu Linux environment
.section .data
value1:
.double 12.34, 2345.543
value2:
.double -5439.234, 32121.4
.section .bss
.lcomm data, 16
.section .text
.globl _start
_start:
nop
movupd value1, %xmm0
movupd value2, %xmm1
movupd %xmm0, %xmm2
movupd %xmm0, data
movl $1, %eax
movl $0, %ebx
int $0x80




sse2double.s ; sse2double.o # windows environment


sse2double.exe




Because the data memory location contains two double-precision floating-point values, we must use the 2gf option of the x command to display both values stored at the memory location.




C:\>as -gstabs -o users\rnz\desktop\sse2double.o users\rnz\desktop\sse2double.s
C:\>ld -o users\rnz\desktop\sse2double.exe users\rnz\desktop\sse2double.o
C:\>gdb -q users\rnz\desktop\sse2double.exe
Reading symbols from users\rnz\desktop\sse2double.exe...done.
(gdb) break 1
Breakpoint 1 at 0x401000: file users\rnz\desktop\sse2double.s, line 1.
(gdb) run
Starting program: C:\users\rnz\desktop\sse2double.exe
[New Thread 1352.0x1c80]
Breakpoint 1, ?? () at users\rnz\desktop\sse2double.s:12
12 nop
(gdb) s
13 movupd value1, %xmm0
(gdb) s
14 movupd value2, %xmm1
(gdb) s
15 movupd %xmm0, %xmm2
(gdb) s
16 movupd %xmm0, data
(gdb) print $xmm0
$1 = {v4_float = {5.84860315e+35, 2.63562489, 1.79352231e-36, 5.07264233}, v2_double = {12.34, 2345.5430000000001}, v16_int8 = {-82, 71, -31, 122, 20, -82, 40, 64, 117, -109, 24, 4, 22, 83, -94, 64}, v8_int16 = {18350, 31457, -20972, 16424, -27787, 1048, 21270, 16546}, v4_int32 = {2061584302, 1076407828, 68719477, 1084379926}, v2_int64 = {4623136420479977390, 4657376318677619573}, uint128 = 85913429005601586953847513200535357358}
(gdb) print $xmm1
$2 = {v4_float = {-1.11704749e+24, -5.66396856, -1.58818684e-23, 6.98026705}, v2_double = {-5439.2340000000004, 32121.400000000001}, v16_int8 = {68, -117, 108, -25, 59, 63, -75, -64, -102, -103, -103, -103, 89, 94, -33, 64}, v8_int16 = {-29884, -6292, 16187, -16203, -26214, -26215, 24153, 16607}, v4_int32 = {-412316860, -1061863621, -1717986918, 1088380505}, v2_int64 = {-4560669521124488380, 4674558677155944858}, uint128 = 86230387575033986983375224144585853764}
(gdb) print $xmm2
$3 = {v4_float = {5.84860315e+35, 2.63562489, 1.79352231e-36, 5.07264233}, v2_double = {12.34, 2345.5430000000001}, v16_int8 = {-82, 71, -31, 122, 20, -82, 40, 64, 117, -109, 24, 4, 22, 83, -94, 64}, v8_int16 = {18350, 31457, -20972, 16424, -27787, 1048, 21270, 16546}, v4_int32 = {2061584302, 1076407828, 68719477, 1084379926}, v2_int64 = {4623136420479977390, 4657376318677619573}, uint128 = 85913429005601586953847513200535357358}
(gdb) x/2gf &data
0x403000 : 0 0
# movl $1, %eax REQUIRED
(gdb) s
17 movl $1, %eax # REQUIRED
(gdb) x/2gf &data # " gf " is not sufficient
0x403000 : 12.34 2345.5430000000001

(gdb) x/2gf &value1
0x402000 : 12.34 2345.5430000000001
(gdb) x/2gf &value2
0x402010 : -5439.2340000000004 32121.400000000001
(gdb) x/16b &data
0x403000 : -82 71 -31 122 20 -82 40 64
0x403008 : 117 -109 24 4 22 83 -94 64
(gdb) x/16b &value1
0x402000 : -82 71 -31 122 20 -82 40 64
0x402008 : 117 -109 24 4 22 83 -94 64
(gdb) x/16b &value2
0x402010 : 68 -117 108 -25 59 63 -75 -64
0x402018 : -102 -103 -103 -103 89 94 -33 64
(gdb) x/32x &data
0x403000 : 0xae 0x47 0xe1 0x7a 0x14 0xae 0x28 0x40
0x403008 : 0x75 0x93 0x18 0x04 0x16 0x53 0xa2 0x40
0x403010: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x403018: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
(gdb) x/16x &data
0x403000 : 0xae 0x47 0xe1 0x7a 0x14 0xae 0x28 0x40
0x403008 : 0x75 0x93 0x18 0x04 0x16 0x53 0xa2 0x40
(gdb) x/16x &value1
0x402000 : 0xae 0x47 0xe1 0x7a 0x14 0xae 0x28 0x40
0x402008 : 0x75 0x93 0x18 0x04 0x16 0x53 0xa2 0x40
(gdb) x/16x &value2
0x402010 : 0x44 0x8b 0x6c 0xe7 0x3b 0x3f 0xb5 0xc0
0x402018 : 0x9a 0x99 0x99 0x99 0x59 0x5e 0xdf 0x40
(gdb)







SSE3 instructions

❑ MOVSHDUP: Moves a 128-bit value from Memory or an XMM register, duplicating the second and fourth 32-bit data elements.
Thus, moving the data element consisting of 32-bit single-precision floating-point values DCBA would create the 128-bit packed single-precision floating-point value consisting of DDBB.

❑ MOVSLDUP: Moves a 128-bit value from Memory or an XMM register, duplicating the first and third 32-bit data elements.
Thus, moving the data element consisting of 32-bit single-precision floating-point values DCBA would create the 128-bit packed single-precision floating-point value consisting of CCAA.

❑ MOVDDUP: Moves a 64-bit double-precision floating-point value from Memory or an XMM register, duplicating it into a 128-bit XMM register.
Thus, moving the data element consisting of 64-bit double-precision floating-point value A would create the 128-bit packed double-precision floating-point value AA.



Home Page