The SetPrecision function
The SetPrecision function sets the number of digits after the point that will be output when working with floating-point numbers. This value is used by other functions that output or format floating-point numbers.
Parameters: AL: a number specifying the count of digits to output after the point.
Return value: The function does not return a value.
Flag state: The function does not modify the flags.
Program source code
An example program for the Intel 8086 assembler demonstrating the use of the SetPrecision function to set the output precision for floating-point numbers.
title .model small .stack 100h data segment public fmtstr db "Number: %f\0" number dq 123.456789 data ends code segment public ; Start of the code segment assume ds:data, cs:code include Handyfar.inc ; Include the file with functions main proc ; Start of the main procedure call SetDataSegment ; Call the SetDataSegment procedure mov al, 4 ; Copy the number 4 into the al register call SetPrecision ; Call the SetPrecision procedure fld qword ptr[number] ; 2nd: Load number onto the top of the math coprocessor stack lea ax, ds:[fmtstr] ; 1st: Load the address of the variable fmtstr into the ds:ax register call PrintFormatString ; Call the PrintFormatString procedure (ax:fmtstr, st(0)) add sp, 2 ; Align the stack xor al, al ; Clear the al register call ExitProcess ; Call the ExitProcess procedure main endp ; End of the main procedure code ends ; End of the code segment end main ; End of file. The main procedure is the entry point
Number: 123.4567
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".