Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/branches/SMLNJ/src/runtime/mach-dep/X86.prim.asm
ViewVC logotype

Diff of /sml/branches/SMLNJ/src/runtime/mach-dep/X86.prim.asm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3, Sat Oct 4 23:33:46 1997 UTC revision 8, Sun Jan 18 01:01:29 1998 UTC
# Line 758  Line 758 
758    
759  #define FPOP    fstp %st        /* Pop the floating point register stack. */  #define FPOP    fstp %st        /* Pop the floating point register stack. */
760    
         DATA  
         ALIGN4  
 maxint_plus1:  
         .long   0x40000000      /* Used in floor_a to check for overflow. */  
 minint_sub1:  
         .long   0xbfffffff  
761    
762  /* Temporary storage for the old and new floating point control  /* Temporary storage for the old and new floating point control
763     word.  We don't use the stack to for this, since doing so would     word.  We don't use the stack to for this, since doing so would
764     change the offsets of the pseudo-registers. */     change the offsets of the pseudo-registers. */
765            DATA
766            ALIGN4
767  old_controlwd:  old_controlwd:
768          .word   0          .word   0
769  new_controlwd:  new_controlwd:
# Line 839  Line 835 
835          ret          ret
836    
837  /* floor : real -> int  /* floor : real -> int
838     Return the nearest integer that is less or equal to the argument,     Return the nearest integer that is less or equal to the argument.
839     or else raise Float("floor") if out of range.  This could be made           Caller's responsibility to make sure arg is in range. */
    more efficient using integer comparisons to check for overflow. */  
840    
841  ML_CODE_HDR(floor_a)  ML_CODE_HDR(floor_a)
842          fstcw   old_controlwd           /* Get FP control word. */          fstcw   old_controlwd           /* Get FP control word. */
# Line 852  Line 847 
847          fldcw   new_controlwd           /* Install new control word. */          fldcw   new_controlwd           /* Install new control word. */
848    
849          fldl    (stdarg)                /* Load argument. */          fldl    (stdarg)                /* Load argument. */
         ficoml  maxint_plus1            /* Compare: arg >= maxint + 1? */  
         fstsw   %ax                     /* Get FP status word. */  
         sahf                            /* Copy to integer status word. */  
         jae     floor_err  
         ficoml  minint_sub1             /* Compare: arg <= maxint + 1? */  
         fstsw   %ax                     /* Get FP status word. */  
         sahf                            /* Copy to integer status word. */  
         jbe     floor_err  
   
850          subl    $4, %esp          subl    $4, %esp
851          fistpl  (%esp)                  /* Round, store, and pop. */          fistpl  (%esp)                  /* Round, store, and pop. */
852          popl    stdarg          popl    stdarg
# Line 869  Line 855 
855    
856          fldcw   old_controlwd           /* Restore old FP control word. */          fldcw   old_controlwd           /* Restore old FP control word. */
857          CONTINUE          CONTINUE
 floor_err:  
         FPOP                            /* Discard argument. */  
         fldcw   old_controlwd           /* Restore old FP control word. */  
         /* signal an overflow */  
         pushf  
         popl    temp  
         orl     $0x800,temp             /* set overflow flag */  
         pushl   temp  
         popf  
         into                            /* can't use "int $4" here since */  
                                         /* signal dispatch looks for into */  
         /* shouldn't get here */  
858    
859  /* logb : real -> int  /* logb : real -> int
860   * Extract the unbiased exponent pointed to by stdarg.   * Extract the unbiased exponent pointed to by stdarg.

Legend:
Removed from v.3  
changed lines
  Added in v.8

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0