1 | 1 | 2 | slog2.sa 3.1 12/10/90 2 | slog2.sa 3.1 12/10/90 3 | 3 | 4 | The entry point slog10 computes the ba !! 4 | The entry point slog10 computes the base-10 5 | logarithm of an input argument X. 5 | logarithm of an input argument X. 6 | slog10d does the same except the input !! 6 | slog10d does the same except the input value is a 7 | denormalized number. !! 7 | denormalized number. 8 | sLog2 and sLog2d are the base-2 analog 8 | sLog2 and sLog2d are the base-2 analogues. 9 | 9 | 10 | INPUT: Double-extended value in memor !! 10 | INPUT: Double-extended value in memory location pointed to 11 | by address register a0. 11 | by address register a0. 12 | 12 | 13 | OUTPUT: log_10(X) or log_2(X) returned !! 13 | OUTPUT: log_10(X) or log_2(X) returned in floating-point 14 | register fp0. 14 | register fp0. 15 | 15 | 16 | ACCURACY and MONOTONICITY: The returne !! 16 | ACCURACY and MONOTONICITY: The returned result is within 1.7 17 | ulps in 64 significant bit, i. !! 17 | ulps in 64 significant bit, i.e. within 0.5003 ulp 18 | to 53 bits if the result is su !! 18 | to 53 bits if the result is subsequently rounded 19 | to double precision. The resul !! 19 | to double precision. The result is provably monotonic 20 | in double precision. 20 | in double precision. 21 | 21 | 22 | SPEED: Two timings are measured, both !! 22 | SPEED: Two timings are measured, both in the copy-back mode. 23 | The first one is measured when !! 23 | The first one is measured when the function is invoked 24 | the first time (so the instruc !! 24 | the first time (so the instructions and data are not 25 | in cache), and the second one !! 25 | in cache), and the second one is measured when the 26 | function is reinvoked at the s 26 | function is reinvoked at the same input argument. 27 | 27 | 28 | ALGORITHM and IMPLEMENTATION NOTES: 28 | ALGORITHM and IMPLEMENTATION NOTES: 29 | 29 | 30 | slog10d: 30 | slog10d: 31 | 31 | 32 | Step 0. If X < 0, create a NaN and r 32 | Step 0. If X < 0, create a NaN and raise the invalid operation 33 | flag. Otherwise, save FPCR i 33 | flag. Otherwise, save FPCR in D1; set FpCR to default. 34 | Notes: Default means round-to-neare 34 | Notes: Default means round-to-nearest mode, no floating-point 35 | traps, and precision control 35 | traps, and precision control = double extended. 36 | 36 | 37 | Step 1. Call slognd to obtain Y = lo 37 | Step 1. Call slognd to obtain Y = log(X), the natural log of X. 38 | Notes: Even if X is denormalized, l 38 | Notes: Even if X is denormalized, log(X) is always normalized. 39 | 39 | 40 | Step 2. Compute log_10(X) = log(X) * 40 | Step 2. Compute log_10(X) = log(X) * (1/log(10)). 41 | 2.1 Restore the user FPCR 41 | 2.1 Restore the user FPCR 42 | 2.2 Return ans := Y * INV_L10. 42 | 2.2 Return ans := Y * INV_L10. 43 | 43 | 44 | 44 | 45 | slog10: !! 45 | slog10: 46 | 46 | 47 | Step 0. If X < 0, create a NaN and r 47 | Step 0. If X < 0, create a NaN and raise the invalid operation 48 | flag. Otherwise, save FPCR i 48 | flag. Otherwise, save FPCR in D1; set FpCR to default. 49 | Notes: Default means round-to-neare 49 | Notes: Default means round-to-nearest mode, no floating-point 50 | traps, and precision control 50 | traps, and precision control = double extended. 51 | 51 | 52 | Step 1. Call sLogN to obtain Y = log 52 | Step 1. Call sLogN to obtain Y = log(X), the natural log of X. 53 | 53 | 54 | Step 2. Compute log_10(X) = log(X) * 54 | Step 2. Compute log_10(X) = log(X) * (1/log(10)). 55 | 2.1 Restore the user FPCR 55 | 2.1 Restore the user FPCR 56 | 2.2 Return ans := Y * INV_L10. 56 | 2.2 Return ans := Y * INV_L10. 57 | 57 | 58 | 58 | 59 | sLog2d: 59 | sLog2d: 60 | 60 | 61 | Step 0. If X < 0, create a NaN and r 61 | Step 0. If X < 0, create a NaN and raise the invalid operation 62 | flag. Otherwise, save FPCR i 62 | flag. Otherwise, save FPCR in D1; set FpCR to default. 63 | Notes: Default means round-to-neare 63 | Notes: Default means round-to-nearest mode, no floating-point 64 | traps, and precision control 64 | traps, and precision control = double extended. 65 | 65 | 66 | Step 1. Call slognd to obtain Y = lo 66 | Step 1. Call slognd to obtain Y = log(X), the natural log of X. 67 | Notes: Even if X is denormalized, l 67 | Notes: Even if X is denormalized, log(X) is always normalized. 68 | 68 | 69 | Step 2. Compute log_10(X) = log(X) * 69 | Step 2. Compute log_10(X) = log(X) * (1/log(2)). 70 | 2.1 Restore the user FPCR 70 | 2.1 Restore the user FPCR 71 | 2.2 Return ans := Y * INV_L2. 71 | 2.2 Return ans := Y * INV_L2. 72 | 72 | 73 | 73 | 74 | sLog2: 74 | sLog2: 75 | 75 | 76 | Step 0. If X < 0, create a NaN and r 76 | Step 0. If X < 0, create a NaN and raise the invalid operation 77 | flag. Otherwise, save FPCR i 77 | flag. Otherwise, save FPCR in D1; set FpCR to default. 78 | Notes: Default means round-to-neare 78 | Notes: Default means round-to-nearest mode, no floating-point 79 | traps, and precision control 79 | traps, and precision control = double extended. 80 | 80 | 81 | Step 1. If X is not an integer power 81 | Step 1. If X is not an integer power of two, i.e., X != 2^k, 82 | go to Step 3. 82 | go to Step 3. 83 | 83 | 84 | Step 2. Return k. 84 | Step 2. Return k. 85 | 2.1 Get integer k, X = 2^k. 85 | 2.1 Get integer k, X = 2^k. 86 | 2.2 Restore the user FPCR. 86 | 2.2 Restore the user FPCR. 87 | 2.3 Return ans := convert-to-dou 87 | 2.3 Return ans := convert-to-double-extended(k). 88 | 88 | 89 | Step 3. Call sLogN to obtain Y = log 89 | Step 3. Call sLogN to obtain Y = log(X), the natural log of X. 90 | 90 | 91 | Step 4. Compute log_2(X) = log(X) * 91 | Step 4. Compute log_2(X) = log(X) * (1/log(2)). 92 | 4.1 Restore the user FPCR 92 | 4.1 Restore the user FPCR 93 | 4.2 Return ans := Y * INV_L2. 93 | 4.2 Return ans := Y * INV_L2. 94 | 94 | 95 95 96 | Copyright (C) Motorola, Inc. 1 96 | Copyright (C) Motorola, Inc. 1990 97 | All Rights Reserved 97 | All Rights Reserved 98 | 98 | 99 | For details on the license for this fi !! 99 | THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA 100 | file, README, in this same directory. !! 100 | The copyright notice above does not evidence any >> 101 | actual or intended publication of such source code. 101 102 102 |SLOG2 idnt 2,1 | Motorola 040 Floating 103 |SLOG2 idnt 2,1 | Motorola 040 Floating Point Software Package 103 104 104 |section 8 105 |section 8 105 106 106 |xref t_frcinx !! 107 |xref t_frcinx 107 |xref t_operr 108 |xref t_operr 108 |xref slogn 109 |xref slogn 109 |xref slognd 110 |xref slognd 110 111 111 INV_L10: .long 0x3FFD0000,0xDE5BD8A9,0x372871 112 INV_L10: .long 0x3FFD0000,0xDE5BD8A9,0x37287195,0x00000000 112 113 113 INV_L2: .long 0x3FFF0000,0xB8AA3B29,0x5C17F0 114 INV_L2: .long 0x3FFF0000,0xB8AA3B29,0x5C17F0BC,0x00000000 114 115 115 .global slog10d 116 .global slog10d 116 slog10d: 117 slog10d: 117 |--entry point for Log10(X), X is denormalized 118 |--entry point for Log10(X), X is denormalized 118 movel (%a0),%d0 119 movel (%a0),%d0 119 blt invalid 120 blt invalid 120 movel %d1,-(%sp) 121 movel %d1,-(%sp) 121 clrl %d1 122 clrl %d1 122 bsr slognd 123 bsr slognd | ...log(X), X denorm. 123 fmovel (%sp)+,%fpcr 124 fmovel (%sp)+,%fpcr 124 fmulx INV_L10,%fp0 125 fmulx INV_L10,%fp0 125 bra t_frcinx 126 bra t_frcinx 126 127 127 .global slog10 128 .global slog10 128 slog10: 129 slog10: 129 |--entry point for Log10(X), X is normalized 130 |--entry point for Log10(X), X is normalized 130 131 131 movel (%a0),%d0 132 movel (%a0),%d0 132 blt invalid 133 blt invalid 133 movel %d1,-(%sp) 134 movel %d1,-(%sp) 134 clrl %d1 135 clrl %d1 135 bsr slogn 136 bsr slogn | ...log(X), X normal. 136 fmovel (%sp)+,%fpcr 137 fmovel (%sp)+,%fpcr 137 fmulx INV_L10,%fp0 138 fmulx INV_L10,%fp0 138 bra t_frcinx 139 bra t_frcinx 139 140 140 141 141 .global slog2d 142 .global slog2d 142 slog2d: 143 slog2d: 143 |--entry point for Log2(X), X is denormalized 144 |--entry point for Log2(X), X is denormalized 144 145 145 movel (%a0),%d0 146 movel (%a0),%d0 146 blt invalid 147 blt invalid 147 movel %d1,-(%sp) 148 movel %d1,-(%sp) 148 clrl %d1 149 clrl %d1 149 bsr slognd 150 bsr slognd | ...log(X), X denorm. 150 fmovel (%sp)+,%fpcr 151 fmovel (%sp)+,%fpcr 151 fmulx INV_L2,%fp0 152 fmulx INV_L2,%fp0 152 bra t_frcinx 153 bra t_frcinx 153 154 154 .global slog2 155 .global slog2 155 slog2: 156 slog2: 156 |--entry point for Log2(X), X is normalized 157 |--entry point for Log2(X), X is normalized 157 movel (%a0),%d0 158 movel (%a0),%d0 158 blt invalid 159 blt invalid 159 160 160 movel 8(%a0),%d0 161 movel 8(%a0),%d0 161 bnes continue 162 bnes continue | ...X is not 2^k 162 163 163 movel 4(%a0),%d0 164 movel 4(%a0),%d0 164 andl #0x7FFFFFFF,%d0 165 andl #0x7FFFFFFF,%d0 165 tstl %d0 166 tstl %d0 166 bnes continue 167 bnes continue 167 168 168 |--X = 2^k. 169 |--X = 2^k. 169 movew (%a0),%d0 170 movew (%a0),%d0 170 andl #0x00007FFF,%d0 171 andl #0x00007FFF,%d0 171 subl #0x3FFF,%d0 172 subl #0x3FFF,%d0 172 fmovel %d1,%fpcr 173 fmovel %d1,%fpcr 173 fmovel %d0,%fp0 174 fmovel %d0,%fp0 174 bra t_frcinx 175 bra t_frcinx 175 176 176 continue: 177 continue: 177 movel %d1,-(%sp) 178 movel %d1,-(%sp) 178 clrl %d1 179 clrl %d1 179 bsr slogn 180 bsr slogn | ...log(X), X normal. 180 fmovel (%sp)+,%fpcr 181 fmovel (%sp)+,%fpcr 181 fmulx INV_L2,%fp0 182 fmulx INV_L2,%fp0 182 bra t_frcinx 183 bra t_frcinx 183 184 184 invalid: 185 invalid: 185 bra t_operr 186 bra t_operr 186 187 187 |end 188 |end
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.