~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/math-emu/reg_norm.S

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*---------------------------------------------------------------------------+
  3  |  reg_norm.S                                                               |
  4  |                                                                           |
  5  | Copyright (C) 1992,1993,1994,1995,1997                                    |
  6  |                       W. Metzenthen, 22 Parker St, Ormond, Vic 3163,      |
  7  |                       Australia.  E-mail billm@suburbia.net               |
  8  |                                                                           |
  9  | Normalize the value in a FPU_REG.                                         |
 10  |                                                                           |
 11  | Call from C as:                                                           |
 12  |    int FPU_normalize(FPU_REG *n)                                          |
 13  |                                                                           |
 14  |    int FPU_normalize_nuo(FPU_REG *n)                                      |
 15  |                                                                           |
 16  |    Return value is the tag of the answer, or-ed with FPU_Exception if     |
 17  |    one was raised, or -1 on internal error.                               |
 18  |                                                                           |
 19  +---------------------------------------------------------------------------*/
 20 
 21 #include "fpu_emu.h"
 22 
 23 
 24 .text
 25 SYM_FUNC_START(FPU_normalize)
 26         pushl   %ebp
 27         movl    %esp,%ebp
 28         pushl   %ebx
 29 
 30         movl    PARAM1,%ebx
 31 
 32         movl    SIGH(%ebx),%edx
 33         movl    SIGL(%ebx),%eax
 34 
 35         orl     %edx,%edx       /* ms bits */
 36         js      L_done          /* Already normalized */
 37         jnz     L_shift_1       /* Shift left 1 - 31 bits */
 38 
 39         orl     %eax,%eax
 40         jz      L_zero          /* The contents are zero */
 41 
 42         movl    %eax,%edx
 43         xorl    %eax,%eax
 44         subw    $32,EXP(%ebx)   /* This can cause an underflow */
 45 
 46 /* We need to shift left by 1 - 31 bits */
 47 L_shift_1:
 48         bsrl    %edx,%ecx       /* get the required shift in %ecx */
 49         subl    $31,%ecx
 50         negl    %ecx
 51         shld    %cl,%eax,%edx
 52         shl     %cl,%eax
 53         subw    %cx,EXP(%ebx)   /* This can cause an underflow */
 54 
 55         movl    %edx,SIGH(%ebx)
 56         movl    %eax,SIGL(%ebx)
 57 
 58 L_done:
 59         cmpw    EXP_OVER,EXP(%ebx)
 60         jge     L_overflow
 61 
 62         cmpw    EXP_UNDER,EXP(%ebx)
 63         jle     L_underflow
 64 
 65 L_exit_valid:
 66         movl    TAG_Valid,%eax
 67 
 68         /* Convert the exponent to 80x87 form. */
 69         addw    EXTENDED_Ebias,EXP(%ebx)
 70         andw    $0x7fff,EXP(%ebx)
 71 
 72 L_exit:
 73         popl    %ebx
 74         leave
 75         RET
 76 
 77 
 78 L_zero:
 79         movw    $0,EXP(%ebx)
 80         movl    TAG_Zero,%eax
 81         jmp     L_exit
 82 
 83 L_underflow:
 84         /* Convert the exponent to 80x87 form. */
 85         addw    EXTENDED_Ebias,EXP(%ebx)
 86         push    %ebx
 87         call    arith_underflow
 88         pop     %ebx
 89         jmp     L_exit
 90 
 91 L_overflow:
 92         /* Convert the exponent to 80x87 form. */
 93         addw    EXTENDED_Ebias,EXP(%ebx)
 94         push    %ebx
 95         call    arith_overflow
 96         pop     %ebx
 97         jmp     L_exit
 98 SYM_FUNC_END(FPU_normalize)
 99 
100 
101 
102 /* Normalise without reporting underflow or overflow */
103 SYM_FUNC_START(FPU_normalize_nuo)
104         pushl   %ebp
105         movl    %esp,%ebp
106         pushl   %ebx
107 
108         movl    PARAM1,%ebx
109 
110         movl    SIGH(%ebx),%edx
111         movl    SIGL(%ebx),%eax
112 
113         orl     %edx,%edx       /* ms bits */
114         js      L_exit_nuo_valid        /* Already normalized */
115         jnz     L_nuo_shift_1   /* Shift left 1 - 31 bits */
116 
117         orl     %eax,%eax
118         jz      L_exit_nuo_zero         /* The contents are zero */
119 
120         movl    %eax,%edx
121         xorl    %eax,%eax
122         subw    $32,EXP(%ebx)   /* This can cause an underflow */
123 
124 /* We need to shift left by 1 - 31 bits */
125 L_nuo_shift_1:
126         bsrl    %edx,%ecx       /* get the required shift in %ecx */
127         subl    $31,%ecx
128         negl    %ecx
129         shld    %cl,%eax,%edx
130         shl     %cl,%eax
131         subw    %cx,EXP(%ebx)   /* This can cause an underflow */
132 
133         movl    %edx,SIGH(%ebx)
134         movl    %eax,SIGL(%ebx)
135 
136 L_exit_nuo_valid:
137         movl    TAG_Valid,%eax
138 
139         popl    %ebx
140         leave
141         RET
142 
143 L_exit_nuo_zero:
144         movl    TAG_Zero,%eax
145         movw    EXP_UNDER,EXP(%ebx)
146 
147         popl    %ebx
148         leave
149         RET
150 SYM_FUNC_END(FPU_normalize_nuo)

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php