The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: coolerfantasy on March 23, 2008, 09:09:16 PM

Title: how to use UTIL.LIB
Post by: coolerfantasy on March 23, 2008, 09:09:16 PM
hi guys
i have UTIL.lib ,it has very good procedures ,but there is one procedure i cant understand yet
that is :
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PutFP       (procedure)

Display a floating point number as a decimal number on the CRT
screen.

usage:

    Input:  FPU stack top ST = the number to be displayed

    EXTRN   PutFP : NEAR
    call    PutFP

    OutPut: The FPU stack has been popped
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
i wonder how to write values i have allready process
thank you .
Title: Re: how to use UTIL.LIB
Post by: MichaelW on March 24, 2008, 01:04:43 AM

;------------------------------------------------------------
; This example is for MASM 6+, and it probably will not work
; for MASM 5.0 without modification.
;------------------------------------------------------------

; This is from util.doc:
;-------------------------------------------------------------
;PutFP       (procedure)
;
;Display a floating point number as a decimal number on the CRT
;screen.
;
;usage:
;
;    Input:  FPU stack top ST = the number to be displayed
;
;    EXTRN   PutFP : NEAR
;    call    PutFP
;
;    OutPut: The FPU stack has been popped
;
;    All registers are preserved
;-------------------------------------------------------------

.model small
.386

;----------------------------------------------------------
; Tell MASM that PutFP is defined in another file, so MASM
; will not expect it to be defined in this file and return
; an error when it is not found in this file:
;  error A2006: undefined symbol : PutFP.
;----------------------------------------------------------

EXTRN PutFP : NEAR

.stack
.data
    val DQ 1234.5678
.code

;--------------------------------------------------
; You probably have an include file pcmac.inc that
; contains a _Begin macro that does this.
;--------------------------------------------------

.startup

    ;-----------------------------------------------------
    ; Load the value into FPU stack top ST and call PutFP.
    ;-----------------------------------------------------

    fld val
    call PutFP

    ;--------------------------------------------------
    ; Wait for the user to press a key before exiting.
    ; You probably have an include file pcmac.inc that
    ; contains a _BIOSCh macro that does this.
    ;--------------------------------------------------

    mov ah, 0h
    int 16h

;--------------------------------------------------
; You probably have an include file pcmac.inc that
; contains a _Exit macro that does this.
;--------------------------------------------------

.exit
 
end
Title: Re: how to use UTIL.LIB
Post by: coolerfantasy on March 24, 2008, 10:29:22 AM
MichaelW
thank you sir

Title: Re: how to use UTIL.LIB
Post by: coolerfantasy on March 24, 2008, 10:50:10 AM
the example worked without errors but it gives only fixed value that is :
3.21043447754e-302
and that is for any value pushed by FLD instruction
Title: Re: how to use UTIL.LIB
Post by: MichaelW on March 24, 2008, 03:46:04 PM
I have no idea what could cause this. Under Windows you normally would not be notified of an FPU error. You might be able to get an idea of what is happening by displaying the FPU status word, like this:

fld val
fstsw ax
call PutHex


This code stores the FPU status word in ax, and then displays the value of ax in hex. If the FPU has detected no errors since the errors were last cleared (by an FINIT or an FCLEX), the lower byte of ax should contain 00h.

Title: Re: how to use UTIL.LIB
Post by: coolerfantasy on March 24, 2008, 09:20:09 PM
MichaelW
its very generous of you to continue with answers
i will try that and i will be back
thank you .