News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

how to use UTIL.LIB

Started by coolerfantasy, March 23, 2008, 09:09:16 PM

Previous topic - Next topic

coolerfantasy

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 .

MichaelW


;------------------------------------------------------------
; 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
eschew obfuscation

coolerfantasy


coolerfantasy

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

MichaelW

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.

eschew obfuscation

coolerfantasy

MichaelW
its very generous of you to continue with answers
i will try that and i will be back
thank you .