我是靠谱客的博主 留胡子宝贝,最近开发中收集的这篇文章主要介绍AT&T汇编中的数字数字类型整数SIMD 整数二进制编码十进制浮点数转换,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

文章目录

  • 数字类型
  • 整数
  • SIMD 整数
  • 二进制编码十进制
  • 浮点数
  • 转换

数字类型

  • 无符号整数
  • 有符号整数
  • 二进制编码十进制
  • 压缩二进制编码十进制
  • 单精度浮点数
  • 双精度浮点数
  • 双扩展浮点数
    SIMD 扩展类型
    • 64位压缩整数
    • 128位压缩整数
    • 128位压缩单精度浮点数
    • 128位压缩双精度浮点数

整数

  • 标准的整数大小
    • Byte
    • Word
    • Doubleword
    • Quadword
  • 无符号整数
  • 有符号整数
# inttest.s - An example of using signed integers
.section .data
data:
.int -45
.section .text
.globl _start
_start:
nop
movl $-345, %ecx
movw $0xffb1, %dx
movl data, %ebx
movl $1, %eax
int $0x80
  • 扩展无符号整数
    • 格式
      movzx source, destination
    • 示例
# movzxtest.s - An example of the MOVZX instruction
.section .text
.globl _start
_start:
nop
movl $279, %ecx
movzx %cl, %ebx
movl $1, %eax
int $0x80
  • 扩展有符号整数
    • 格式
      movsx source, destination
    • 示例
# movsxtest.s - An example of the MOVSX instruction
.section .text
.globl _start
_start:
nop
movw $-79, %cx
movl $0, %ebx
movw %cx, %bx
movsx %cx, %eax
movl $1, %eax
movl $0, %ebx
int $0x80
  • 在GAS中定义整数
    • 示例
# quadtest.s - An example of quad integers
.section .data
data1:
.int 1, -1, 463345, -333252322, 0
data2:
.quad 1, -1, 463345, -333252322, 0
.section .text
.globl _start
_start:
nop
movl $1, %eax
movl $0, %ebx
int $0x80

SIMD 整数

  • MMX整数
    • 64位压缩字节整数
    • 64位压缩字整数
    • 64位压缩双字整数
  • 移动MMX整数
    • 格式
      movq source, destination
    • 示例
# mmxtest.s - An example of using the MMX data types
.section .data
values1:
.int 1, -1
values2:
.byte 0x10, 0x50, 0xff, 0x32, 0x47, 0xe4, 0x00, 0x01
.section .text
.globl _start
_start:
nop
movq values1, %mm0
movq values2, %mm1
movl $1, %eax
movl $0, %ebx
int $0x80
  • SSE 整数
    • 128位压缩字节整数
    • 128位压缩字整数
    • 128位压缩双字整数
    • 128位压缩四字整数
  • 移动SSE整数
    • 格式
      movdqa source, destination
    • 示例
# ssetest.s - An example of using 128-bit SSE registers
.section .data
values1:
.int 1, -1, 0, 135246
values2:
.quad 1, -1
.section .text
.globl _start
_start:
nop
movdqu values1, %xmm0
movdqu values2, %xmm1
movl $1, %eax
movl $0, %ebx
int $0x80

二进制编码十进制

  • BCD编码
  • FPU BCD 值
    • 格式
      • fbld source 存入
      • fbstp source 取出
    • 示例
# bcdtest.s - An example of using BCD integer values
.section .data
data1:
.byte 0x34, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00
data2:
.int 2
.section .text
.globl _start
_start:
nop
fbld data1
fimul data2
fbstp data1
movl $1, %eax
movl $0, %ebx
int $0x80

浮点数

  • 概念
    • 科学计数法
    • 二进制标记法
  • 标准的浮点数类型
    • 组成部分
      • 标志位
      • 有效数字
      • 指数
  • IA-32 浮点数的值
数据类型长度有效数字长度指数长度范围
单精度322481.1810^-38 ~ 3.4010^38
双精度6453112.2310^-308 ~ 1.7910^308
扩展8064153.3710^-4932 ~ 1.1810^4932
  • 浮点数格式
    • .float
    • .double
  • 移动浮点数
    • 格式
      fld source
    • 示例
# floattest.s - An example of using floating point numbers
.section .data
value1:
.float 12.34
values2:
.double 2353.631
.section .bss
.lcomm data, 8
.section .text
.globl _start
_start:
nop
flds values1
fldl values2
fstl data
movl $1, %eax
movl $0, %ebx
int $0x80
  • 使用预置的浮点值
指令描述
FLD11.0 -> stack
FLDL2Tlog(base2)10 ->stack
FLDL2Elog(base2)e -> stack
FLDPIpi -> stack
FLDLG2log(base 10)2 -> stack
FLDLN2log(base e)2 -> stack
FLDZ0 -> stack
* 示例
# fpuvals.s - An example of pushing floating point constants
.section .text
.globl _start
_start:
nop
fld1
fldl2t
fldl2e
fldpi
fldlg2
fldln2
fldz
movl $1, %eax
movl $0, %ebx
int $0x80
  • SSE 浮点类型
    • 单精度
指令描述
MOVAPS将4个对齐的单精度浮点数移动到寄存器或内存
MOVUPS将4个非对齐的单精度浮点数值移动到寄存器或内存
MOVSS将一个单精度浮点数移动到内存或一个寄存器的低双字
MOVLPS将两个单精度浮点数移动到内存或低四字寄存器
MOVHPS将两个单精度浮点数移动到内存或高四字寄存器
MOVLHPS从寄存器的低四字取出两个单精度浮点数
MOVHLPS从寄存器的高四字取出两个单精度浮点数
* 示例
# 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.00003
.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
* 双精度
指令描述
MOVAPD将两个对齐的双精度浮点数移动到xmm寄存器
MOVUPD将两个非对齐的双精度浮点数移动到xmm寄存器
MOVSD将一个双精度的浮点数移动到内存或寄存器的低四字
MOVHPD将一个双精度浮点数移动到内存或寄存器的高四字
MOVLPD将一个双精度的浮点数移动到内存或低四字寄存器
	* 示例
# 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

转换

  • 转换指令
指令描述
CVTDQ2PD压缩双字整数转换成压缩双精度浮点数
CVTDQ2PS压缩双字整数转换成单精度浮点数
CVTPD2DQ将两个压缩双精度浮点数转换成双字整数
CVTPD2PI将两个压缩双精度浮点数转换成双字整数
CVTPD2PS将两个双精度浮点数转换成压缩单精度浮点数
CVTPI2PD将压缩双字整数转换成压缩双精度浮点数
CVTPI2PS将压缩双字整数转换成单精度浮点数
CVTPS2DQ将压缩单精度浮点数转换成双字整数
CVTPS2PD将压缩单精度浮点数转换成压缩双精度浮点数
CVTPS2PI将压缩单精度浮点数转换成双字整数
CVTTPD2PI将压缩双精度浮点数转换成压缩双字整数
CVTTPD2DQ将压缩双精度浮点数转换成压缩双字整数
CVTTPS2DQ将压缩单精度浮点数转换成压缩双字整数
CVTTPS2PI将压缩单精度浮点数转换成压缩双字整数
  • 示例
# 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
data:
.lcomm data, 16
.section .text
.globl _start
_start:
nop
cvtps2dq value1, %xmm0
cvttps2dq value1, %xmm1
cvcvtdq2ps value2, %xmm2
movdqu %xmm0, data
movl $1, %eax
movl $0, %ebx
int $0x80

最后

以上就是留胡子宝贝为你收集整理的AT&T汇编中的数字数字类型整数SIMD 整数二进制编码十进制浮点数转换的全部内容,希望文章能够帮你解决AT&T汇编中的数字数字类型整数SIMD 整数二进制编码十进制浮点数转换所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(60)

评论列表共有 0 条评论

立即
投稿
返回
顶部