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/trunk/src/runtime/mach-dep/X86.prim.masm
ViewVC logotype

Diff of /sml/trunk/src/runtime/mach-dep/X86.prim.masm

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

revision 2, Sat Oct 4 23:33:09 1997 UTC revision 9, Sun Jan 18 01:01:29 1998 UTC
# Line 781  Line 781 
781    
782  #define FPOP    fstp FP_REG(st) /* Pop the floating point register stack. */  #define FPOP    fstp FP_REG(st) /* Pop the floating point register stack. */
783    
         DATA  
         ALIGN4  
 GLOBAL(maxint_plus1)  
 WORD32(maxint_plus1,HEXLIT(40000000))  /* Used in floor_a to check for overflow. */  
 GLOBAL(minint_sub1)  
 WORD32(minint_sub1,HEXLIT(bfffffff))  
   
784  /* Temporary storage for the old and new floating point control  /* Temporary storage for the old and new floating point control
785     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
786     change the offsets of the pseudo-registers. */     change the offsets of the pseudo-registers. */
787            DATA
788            ALIGN4
789  GLOBAL(old_controlwd)  GLOBAL(old_controlwd)
790  WORD16(old_controlwd,0)  WORD16(old_controlwd,0)
791  GLOBAL(new_controlwd)  GLOBAL(new_controlwd)
# Line 867  Line 862 
862          RET          RET
863    
864  /* floor : real -> int  /* floor : real -> int
865     Return the nearest integer that is less or equal to the argument,     Return the nearest integer that is less or equal to the argument.
866     or else raise Float("floor") if out of range.  This could be made     Caller's responsibility to make argument in range. */
    more efficient using integer comparisons to check for overflow. */  
867    
868  ML_CODE_HDR(floor_a)  ML_CODE_HDR(floor_a)
869          /* Get FP control word. */          /* Get FP control word. */
# Line 883  Line 877 
877          fldcw   new_controlwd           /* Install new control word. */          fldcw   new_controlwd           /* Install new control word. */
878    
879          FLDL    IND_OFF(REAL8,stdarg,0) /* Load argument. */          FLDL    IND_OFF(REAL8,stdarg,0) /* Load argument. */
         FICOML  maxint_plus1            /* Compare: arg >= maxint + 1? */  
         fstsw   REG(ax)                 /* Get FP status word. */  
         sahf                            /* Copy to integer status word. */  
         jae     floor_err  
         FICOML  minint_sub1             /* Compare: arg <= maxint + 1? */  
         fstsw   REG(ax)                 /* Get FP status word. */  
         sahf                            /* Copy to integer status word. */  
         jbe     floor_err  
   
880          SUBL    (IMMED(4), REG(esp))          SUBL    (IMMED(4), REG(esp))
881          FISTPL  IND_DW_OFF(REG(esp),0)  /* Round, store, and pop. */          FISTPL  IND_DW_OFF(REG(esp),0)  /* Round, store, and pop. */
882          POPL    stdarg          POPL    stdarg
# Line 900  Line 885 
885    
886          fldcw   old_controlwd           /* Restore old FP control word. */          fldcw   old_controlwd           /* Restore old FP control word. */
887          CONTINUE          CONTINUE
 floor_err:  
         FPOP                            /* Discard argument. */  
         fldcw   old_controlwd           /* Restore old FP control word. */  
         /* signal an overflow */  
         pushf  
         POPL    temp  
         ORL     (IMMED(HEXLIT(800)),temp)       /* set overflow flag */  
         PUSHL   temp  
         popf  
         into                            /* can't use "int $4" here since */  
                                         /* signal dispatch looks for into */  
         /* shouldn't get here */  
   
888    
889  /* logb : real -> int  /* logb : real -> int
890   * Extract the unbiased exponent pointed to by stdarg.   * Extract the unbiased exponent pointed to by stdarg.

Legend:
Removed from v.2  
changed lines
  Added in v.9

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