有关汇编的文章与代码
;浮点型指令编程--计算平方和的平方根程序
;find the square root of the sum of the squares of two floating point numbers
;Author:lionel.shen
;Date:revised 10/2009
.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall,dwExitCode:DWORD
.STACK 4096
.DATA
value1 REAL4 0.5
value2 REAL4 1.2
sqrt REAL4 ?
.CODE
_start:
finit ;initialize floating point unit
fld value1 ;value1 in ST 实现从存储器复制value1值给ST
fld st ;value1 in ST and ST(1) 把value从ST复制给ST,并把第一个堆栈的值下移到ST(1)
fmul ;value1*value1 in ST 在ST中计算value1*value1的值,同时ST(1)的值“清空“
fld value2 ;value1 in ST(value1*value1 in ST(1))
fld st ;value2 in ST and ST(1)
fmul ;value2*value2 in ST
fadd ;sum of squares in ST
fsqrt ;square root of sum of squares in ST
fstp sqrt ;store result,clearing stack
INVOKE ExitProcess,0
PUBLIC _start
END
//个人所添注释
finit指令确保FPU寄存器的内容能被清空