SSE floating-point data types (SSE中的浮点数据类型):除了前面章节介绍的几个标准浮点数据类型外,在SSE技术中还引入了两种高级的浮点数据类型:128-bit packed single-precisio...
|
# ssefloat.s - An example of moving SSE FP data types .section .data value1: .float 12.34, 2345.543, -3493.2, 0.44901 value2: .float -5439.234, 32121.4, 1.0094, 0.000003 .section .bss .lcomm data, 16 .section .text .globl _start _start: nop movups value1, %xmm0 movups value2, %xmm1 movups %xmm0, %xmm2 movups %xmm0, data movl $1, %eax movl $0, %ebx int $0x80 |
$ as -gstabs -o ssefloat.o ssefloat.s $ ld -o ssefloat ssefloat.o $ gdb -q ssefloat Reading symbols from /home/zengl/Downloads/asm_example/ssetest/ssefloat...done. (gdb) break *_start+1 Breakpoint 1 at 0x8048075: file ssefloat.s, line 13. (gdb) r Starting program: /home/zengl/Downloads/asm_example/ssetest/ssefloat Breakpoint 1, _start () at ssefloat.s:13 13 movups value1, %xmm0 (gdb) s 14 movups value2, %xmm1 (gdb) s 15 movups %xmm0, %xmm2 (gdb) s 16 movups %xmm0, data (gdb) print $xmm0 $1 = {v4_float = {12.3400002, 2345.54297, -3493.19995, 0.449010015}, v2_double = {5.6204289471764299e+24, 1.0439462282443856e-05}, v16_int8 = {-92, 112, 69, 65, -80, -104, 18, 69, 51, 83, 90, -59, -92, -28, -27, 62}, v8_int16 = {28836, 16709, -26448, 17682, 21299, -15014, -7004, 16101}, v4_int32 = {1095069860, 1158846640, -983936205, 1055253668}, v2_int64 = {4977208420974555300, 4532279996355072819}, uint128 = 0x3ee5e4a4c55a5333451298b0414570a4} (gdb) print $xmm1 $2 = {v4_float = {-5439.23389, 32121.4004, 1.00940001, 3.00000011e-06}, v2_double = {8.7452727745837517e+33, 3.4658329842889617e-47}, v16_int8 = {-33, -7, -87, -59, -51, -14, -6, 70, 5, 52, -127, 63, -100, 83, 73, 54}, v8_int16 = {-1569, -14935, -3379, 18170, 13317, 16257, 21404, 13897}, v4_int32 = {-978716193, 1190851277, 1065432069, 910775196}, v2_int64 = {5114667292431088095, 3911749681893422085}, uint128 = 0x3649539c3f81340546faf2cdc5a9f9df} (gdb) print $xmm2 $3 = {v4_float = {12.3400002, 2345.54297, -3493.19995, 0.449010015}, v2_double = {5.6204289471764299e+24, 1.0439462282443856e-05}, v16_int8 = {-92, 112, 69, 65, -80, -104, 18, 69, 51, 83, 90, -59, -92, -28, -27, 62}, v8_int16 = {28836, 16709, -26448, 17682, 21299, -15014, -7004, 16101}, v4_int32 = {1095069860, 1158846640, -983936205, 1055253668}, v2_int64 = {4977208420974555300, 4532279996355072819}, uint128 = 0x3ee5e4a4c55a5333451298b0414570a4} (gdb) |
16 movups %xmm0, data (gdb) s 18 movl $1, %eax (gdb) x/4wf &data 0x80490c0 <data>: 12.3400002 2345.54297 -3493.19995 0.449010015 (gdb) |
(gdb) x/16bx &data 0x80490c0 <data>: 0xa4 0x70 0x45 0x41 0xb0 0x98 0x12 0x45 0x80490c8 <data+8>: 0x33 0x53 0x5a 0xc5 0xa4 0xe4 0xe5 0x3e (gdb) x/16bx &value1 0x804909c <value1>: 0xa4 0x70 0x45 0x41 0xb0 0x98 0x12 0x45 0x80490a4 <value1+8>: 0x33 0x53 0x5a 0xc5 0xa4 0xe4 0xe5 0x3e (gdb) |
|
# sse2float.s - An example of moving SSE2 FP data types .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 |
$ as -gstabs -o sse2float.o sse2float.s $ ld -o sse2float sse2float.o $ gdb -q sse2float Reading symbols from /home/zengl/Downloads/asm_example/ssetest/sse2float...done. (gdb) break *_start+1 Breakpoint 1 at 0x8048075: file sse2float.s, line 13. (gdb) r Starting program: /home/zengl/Downloads/asm_example/ssetest/sse2float Breakpoint 1, _start () at sse2float.s:13 13 movupd value1, %xmm0 (gdb) s 14 movupd value2, %xmm1 (gdb) s 15 movupd %xmm0, %xmm2 (gdb) s 16 movupd %xmm0, data (gdb) s 18 movl $1, %eax (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 = 0x40a25316041893754028ae147ae147ae} (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 = 0x40df5e599999999ac0b53f3be76c8b44} (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 = 0x40a25316041893754028ae147ae147ae} (gdb) x/2gf &data 0x80490c0 <data>: 12.34 2345.5430000000001 (gdb) |
# ssefloat.s - An example of moving SSE FP data types .section .data .align 16 value1: .float 12.34, 2345.543, -3493.2, 0.44901 value2: .float -5439.234, 32121.4, 1.0094, 0.000003 .section .bss .lcomm data, 16 .section .text .globl _start _start: nop movups value1, %xmm0 movups value2, %xmm1 movshdup %xmm0, %xmm2 movups %xmm0, data movsldup data,%xmm1 movl $1, %eax movl $0, %ebx int $0x80 |
(gdb) s 16 movshdup %xmm0, %xmm2 (gdb) s 17 movups %xmm0, data (gdb) print $xmm0 $1 = {v4_float = {12.3400002, 2345.54297, -3493.19995, 0.449010015}, ...................... //省略其他输出 (gdb) print $xmm2 $2 = {v4_float = {2345.54297, 2345.54297, 0.449010015, 0.449010015}, ...................... //省略其他输出 (gdb) |
17 movups %xmm0, data (gdb) s 18 movsldup data,%xmm1 (gdb) s 20 movl $1, %eax (gdb) x/4wf &data 0x80490d0 <data>: 12.3400002 2345.54297 -3493.19995 0.449010015 (gdb) print $xmm1 $4 = {v4_float = {12.3400002, 12.3400002, -3493.19995, -3493.19995}, ...................... //省略其他输出 (gdb) |
# sse2float.s - An example of moving SSE2 FP data types .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 movddup value1, %xmm0 movupd value2, %xmm1 movupd %xmm0, %xmm2 movupd %xmm0, data movl $1, %eax movl $0, %ebx int $0x80 |
13 movddup value1, %xmm0 (gdb) s 14 movupd value2, %xmm1 (gdb) x/2gf &value1 0x80490a0 <value1>: 12.34 2345.5430000000001 (gdb) print $xmm0 ...................... //省略其他输出 v2_double = {12.34, 12.34}, ...................... //省略其他输出 (gdb) |
|
CVTTPS2PI site:www.jaist.ac.jp |
# convtest.s - An example of data conversion .section .data value1: .float 1.25, 124.79, 200.0, -312.5 value2: .int 1, -435, 0, -25 .section .bss .lcomm data, 16 .section .text .globl _start _start: nop cvtps2dq value1, %xmm0 cvttps2dq value1, %xmm1 cvtdq2ps value2, %xmm2 movdqu %xmm0, data movl $1, %eax movl $0, %ebx int $0x80 |
$ as -gstabs -o convtest.o convtest.s $ ld -o convtest convtest.o $ gdb -q convtest Reading symbols from /home/zengl/Downloads/asm_example/ssetest/convtest...done. (gdb) break *_start+1 Breakpoint 1 at 0x8048075: file convtest.s, line 13. (gdb) r Starting program: /home/zengl/Downloads/asm_example/ssetest/convtest Breakpoint 1, _start () at convtest.s:13 13 cvtps2dq value1, %xmm0 (gdb) s 14 cvttps2dq value1, %xmm1 (gdb) s 15 cvtdq2ps value2, %xmm2 (gdb) s 16 movdqu %xmm0, data (gdb) s 17 movl $1, %eax (gdb) print $xmm0 ...................... //省略其他输出 v4_int32 = {1, 125, 200, -312}, ...................... //省略其他输出 (gdb) print $xmm1 ...................... //省略其他输出 v4_int32 = {1, 124, 200, -312}, ...................... //省略其他输出 (gdb) print $xmm2 $3 = {v4_float = {1, -435, 0, -25}, ...................... //省略其他输出 (gdb) x/4wd &data 0x80490c0 <data>: 1 125 200 -312 (gdb) |