永发信息网

浮点运算的指令系统分类

答案:1  悬赏:20  手机版
解决时间 2021-11-19 15:44
  • 提问者网友:玫瑰园
  • 2021-11-18 21:33
浮点运算的指令系统分类
最佳答案
  • 五星知识达人网友:渡鹤影
  • 2021-11-18 23:12
浮点指令系统分为五类:数据传送类、算术运算类、超越函数类、比较类、环境及系统控制类.
我并不想列出所有函数的参数以及用法,具体参考资料见文章最后.
1、数据传送类
这类指令主要是从内存装入浮点寄存器堆数据,一般目的地址总是栈顶ST(0),用调试器你可以清楚地看到这一点.注意带P结尾的操作,是在前面操作完成之后出栈,也就是原来ST(1)的内容现在成了ST(0)的内容,注意到这一点,你可以方便地设计出灵活多变的程序.
装入:
FLD Push real onto stack
FILD Convert two's complement integer to real and push
FBLD Convert BCD to real and push to stack
存储:
FST Store floating-point number from stack
FSTP Convert top of stack to integer
FIST
FISTP Convert top of stack to integer
FBSTP Store BCD to integer and pop stack
交换:
FXCH Exchange top two stack elements
常数装载:
FLD1 装入常数1.0
FLDZ 装入常数0.0
FLDPI 装入常数pi (=3.1415926....精度足够,放心使用)
FLDL2E 装入常数log(2)e
FLDL2T 装入常数log(2)10
FLDLG2 装入常数log(10)2
FLDLN2 装入常数Log(e)2
2、算术运算类
加法:
FADD/FADDP Add/add and pop
FIADD Integer add
减法:
FSUB/FSUBP Subtract/subtract and pop
FSUBR/FSUBRP Subtract/subtract and pop with reversed operands
FISUB Integer subtract
FISUBR Integer subtract/subtract with reversed operands
乘法:
FMUL/FMULP Multiply/multiply and pop
FIMUL Integer multiply
除法:
FDIV/FDIVP Divide/divide and pop
FIDIV Integer divide
FDIVR/FDIVRP Divide/divide and pop with reversed operands
FIDIVR integer divide with reversed operands
其他:
FABS Calculate absolute value
FCHS Change sign
FRNDINT Round to integer
FSQRT Calculate square root
FSCALE Scale top of stack by power of 2
FXTRACT Separate exponent and mantissa
FPREM Calculate partial remainder
FPREM1 Calculate partial remainder in IEEE format
如果指令后面未带操作数,其默认的操作数为ST(0)和ST(1),关于带R后缀的指令是正常操作数的顺序变反,比如fsub执行的是x-y,fsubr执行的就是y-x.
3、超越函数类
三角函数
FSIN Calculate sine
FCOS Calculate cosine
FSINCOS Calculate quick sine and cosine
FPTAN Calculate partial tangent
FPATAN Calculate partial arctangent
Log类
FYL2X Calculate y times log base 2 of x
FYL2XP1 Calculate y times log base 2 of (x+1)
F2XM1 Calculate (2^x)-1
4、比较类
FCOM Compare
FCOMP Compare and pop
FICOM Integer compare
FTST Integer compare and pop
FUCOM Unordered compare
FUCOMP Unordered compare and pop
FXAM Set condition code bits for value at top of stack
FSTSW Store status word
会根据结果设置,C0~C3,在上面并未就C0~C3进行具体介绍,C1是用来判断上溢或者下溢的,C0相当于EFLAGS里面的CF,作用也基本一致,C2相当于PF,C3相当于ZF,可能会看到如下指令
FSTSW ax
SAHF
JZ label
为什么如此呢,因为用如上指令将状态字存入EFLAGS,C0正好置于CF位,C3正好置于ZF位.
5、环境及系统控制类
FLDCW Load control word
FSTCW Store control word
FSTSW Store status word
FLDENV Load environment block
FSTENV Store environment block
FSAVE Save coprocessor state
FRSTOR Restore coprocessor state
FINIT Initialize coprocessor
FCLEX Clear exception flags
FINCSTP Increment stack pointer
FDECSTP Decrement stack pointer
FFREE Mark element as free
FNOP No operation
FWAIT Wait until floating-point instruction complete

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯