;--------------------------------------------------------------------------------------------------------------
   ;this will out put floating point value to the screen

;--------------------------------------------------------------------------------------------------------------

  use16
  org  100h


  main:

    xor        ah,ah
    int        16h


    finit			   ;resetting all registers and flags to their default values
    fld        [float1] 	   ;x


    call       fndNum



  .prnt:


    mov        dx,ansStr
    mov        ah,9h
    int        21h

  exitProg:
    xor        ah,ah
    int        16h
    mov        ax,4c00h
    int        21h









  fndNum:

  .rndAndSave:
    fld        st		   ;duplicate top register so	x,x
    fabs
    call       chgCnWd		   ;change RC of the control word

    fist       [num]		   ;int x,x
    call       rvrtCnWd 	   ;revert to defalt value of control word

  mkAnsStr:

    mov        ebx,10
    mov        di,ansStr+20

    mov        al,24h
    std
    stosb
    mov        eax,[num]

  .dvLoop:
    cmp        eax,0
    jz	       .cmplt
    xor        edx,edx
    div        ebx
    push       eax
    add        dl,30h
    mov        al,dl
    std
    stosb
    pop        eax
    jmp        .dvLoop


  .cmplt:
    ret
 ;------------------------------------------------------------------------------------------------------


;------------------------------------------------------------------------------------------------------------------
 chgCnWd:
    fstcw      [svSw]		  ;save control word
    fwait
    mov        ax,[svSw]
    or	       ax,0c00h 	     ;set RC bits to 1 1 and keep other bits
    xchg       ax,[svSw]
    fldcw      [svSw]		  ;set control word to truncate
    xchg       ax,[svSw]
    ret
;------------------------------------------------------------------------------------------------------------------

 rvrtCnWd:
    fldcw      [svSw]
    ret

;------------------------------------------------------------------------------------------------------------------



 ;---------------------------------------data------------------------------------------------------------------



 float1     dd	 4789640.889
 zeroval    dd	 0.0
 oneval     dd	 1
 tenval     dd	 10
 ;onetenth   dd   0.1
 svSw	    dw	 0
 ;adjexpo    dw   0
 ;adjexpo    db   0
 ;expVal     dw   0
 num	    dd	 0.0
 multi	    dd	 1000000000
 charPostn  db	 0
 ;loopnum    db   0
 ansStr     db	 20 dup (0)