SetPrecisionEx 函数
SetPrecisionEx 函数设置输出实数时小数点后的位数。参数通过栈传递。函数会自动将栈对齐 2 个字节。
参数(栈): 1. 小数点后的位数。
返回值: 函数不返回值。
标志状态: 函数不改变标志状态。
程序源代码
Intel 8086 汇编程序示例,演示使用 SetPrecisionEx 函数设置输出实数时的精度。
title .286C .model small .stack 100h data segment public fmtout db "%f + %f = %f\0" number1 dq 23.4562 number2 dq 51.6847 data ends code segment public assume ds:data, cs:code include Handyfar.inc ; 包含函数文件 include Handymac.inc ; 包含宏文件 main proc call SetDataSegment ; 调用过程 SetDataSegment push 3 ; 将数字 3 压入栈顶 call SetPrecisionEx ; 调用过程 SetPrecisionEx(3) fld qword ptr[number1] ; 将变量 number1 压入数学协处理器栈顶 fadd qword ptr[number2] ; number1 + number2(结果保留在数学栈顶) fld qword ptr[number2] ; 第3步:将变量 number2 装入数学协处理器栈顶 fld qword ptr[number1] ; 第2步:将变量 number1 装入数学协处理器栈顶 leaax ds:[fmtout] ; 第1步:将格式字符串 fmtout 的地址装入寄存器 ds:ax call PrintFormatString ; 调用过程 PrintFormatString(ax:fmtout, ...) push 0 ; 将字节值(返回代码)压入栈顶 call ExitProcessEx ; 调用过程 ExitProcessEx(0) main endp code ends end main
23.456 + 51.684 = 75.140
示例取自教材 "HANDYFAR - MASM (Dovgopolov Evgeny Sergeevich)".