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

TOMOYO Linux Cross Reference
Linux/arch/m68k/fpsp040/bindec.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 ] ~

Diff markup

Differences between /arch/m68k/fpsp040/bindec.S (Version linux-6.12-rc7) and /arch/i386/fpsp040/bindec.S (Version linux-5.16.20)


  1 |                                                 
  2 |       bindec.sa 3.4 1/3/91                      
  3 |                                                 
  4 |       bindec                                    
  5 |                                                 
  6 |       Description:                              
  7 |               Converts an input in extended     
  8 |               to bcd format.                    
  9 |                                                 
 10 |       Input:                                    
 11 |               a0 points to the input extende    
 12 |               value in memory; d0 contains t    
 13 |               to 32-bits.  The input may be     
 14 |               unnormalized, or denormalized.    
 15 |                                                 
 16 |       Output: result in the FP_SCR1 space on    
 17 |                                                 
 18 |       Saves and Modifies: D2-D7,A2,FP2          
 19 |                                                 
 20 |       Algorithm:                                
 21 |                                                 
 22 |       A1.     Set RM and size ext;  Set SIGM    
 23 |               The k-factor is saved for use     
 24 |               BINDEC_FLG for separating norm    
 25 |               input.  If input is unnormaliz    
 26 |               normalize it.                     
 27 |                                                 
 28 |       A2.     Set X = abs(input).               
 29 |                                                 
 30 |       A3.     Compute ILOG.                     
 31 |               ILOG is the log base 10 of the    
 32 |               approximated by adding e + 0.f    
 33 |               value is viewed as 2^^e * 1.f     
 34 |               This value is stored in d6.       
 35 |                                                 
 36 |       A4.     Clr INEX bit.                     
 37 |               The operation in A3 above may     
 38 |                                                 
 39 |       A5.     Set ICTR = 0;                     
 40 |               ICTR is a flag used in A13.  I    
 41 |               loop entry A6.                    
 42 |                                                 
 43 |       A6.     Calculate LEN.                    
 44 |               LEN is the number of digits to    
 45 |               k-factor can dictate either th    
 46 |               if it is a positive number, or    
 47 |               after the decimal point which     
 48 |               significant.  See the 68882 ma    
 49 |               If LEN is computed to be great    
 50 |               USER_FPSR.  LEN is stored in d    
 51 |                                                 
 52 |       A7.     Calculate SCALE.                  
 53 |               SCALE is equal to 10^ISCALE, w    
 54 |               of decimal places needed to in    
 55 |               in the output before conversio    
 56 |               sign of ISCALE, used in A9. Fp    
 57 |               10^^(abs(ISCALE)) using a roun    
 58 |               function of the original round    
 59 |               of ISCALE and X.  A table is g    
 60 |                                                 
 61 |       A8.     Clr INEX; Force RZ.               
 62 |               The operation in A3 above may     
 63 |               RZ mode is forced for the scal    
 64 |               only one rounding error.  The     
 65 |               the INEX flag for use in A10.     
 66 |                                                 
 67 |       A9.     Scale X -> Y.                     
 68 |               The mantissa is scaled to the     
 69 |               significant digits.  The exces    
 70 |               in INEX2.                         
 71 |                                                 
 72 |       A10.    Or in INEX.                       
 73 |               If INEX is set, round error oc    
 74 |               compensated for by 'or-ing' in    
 75 |               the lsb of Y.                     
 76 |                                                 
 77 |       A11.    Restore original FPCR; set siz    
 78 |               Perform FINT operation in the     
 79 |               Keep the size to extended.        
 80 |                                                 
 81 |       A12.    Calculate YINT = FINT(Y) accor    
 82 |               mode.  The FPSP routine sintd0    
 83 |               is in fp0.                        
 84 |                                                 
 85 |       A13.    Check for LEN digits.             
 86 |               If the int operation results i    
 87 |               or less than LEN -1 digits, ad    
 88 |               A6.  This test occurs only on     
 89 |               result is exactly 10^LEN, decr    
 90 |               the mantissa by 10.               
 91 |                                                 
 92 |       A14.    Convert the mantissa to bcd.      
 93 |               The binstr routine is used to     
 94 |               mantissa to bcd in memory.  Th    
 95 |               to be a fraction; i.e. (mantis    
 96 |               such that the decimal point is    
 97 |               The bcd digits are stored in t    
 98 |               the final string area in memor    
 99 |                                                 
100 |       A15.    Convert the exponent to bcd.      
101 |               As in A14 above, the exp is co    
102 |               digits are stored in the final    
103 |               Test the length of the final e    
104 |               length is 4, set operr.           
105 |                                                 
106 |       A16.    Write sign bits to final strin    
107 |                                                 
108 |       Implementation Notes:                     
109 |                                                 
110 |       The registers are used as follows:        
111 |                                                 
112 |               d0: scratch; LEN input to bins    
113 |               d1: scratch                       
114 |               d2: upper 32-bits of mantissa     
115 |               d3: scratch;lower 32-bits of m    
116 |               d4: LEN                           
117 |               d5: LAMBDA/ICTR                   
118 |               d6: ILOG                          
119 |               d7: k-factor                      
120 |               a0: ptr for original operand/f    
121 |               a1: scratch pointer               
122 |               a2: pointer to FP_X; abs(origi    
123 |               fp0: scratch                      
124 |               fp1: scratch                      
125 |               fp2: scratch                      
126 |               F_SCR1:                           
127 |               F_SCR2:                           
128 |               L_SCR1:                           
129 |               L_SCR2:                           
130                                                   
131 |               Copyright (C) Motorola, Inc. 1    
132 |                       All Rights Reserved       
133 |                                                 
134 |       For details on the license for this fi    
135 |       file, README, in this same directory.     
136                                                   
137 |BINDEC    idnt    2,1 | Motorola 040 Floating    
138                                                   
139 #include "fpsp.h"                                 
140                                                   
141         |section        8                         
142                                                   
143 | Constants in extended precision                 
144 LOG2:   .long   0x3FFD0000,0x9A209A84,0xFBCFF7    
145 LOG2UP1:        .long   0x3FFD0000,0x9A209A84,    
146                                                   
147 | Constants in single precision                   
148 FONE:   .long   0x3F800000,0x00000000,0x000000    
149 FTWO:   .long   0x40000000,0x00000000,0x000000    
150 FTEN:   .long   0x41200000,0x00000000,0x000000    
151 F4933:  .long   0x459A2800,0x00000000,0x000000    
152                                                   
153 RBDTBL: .byte   0,0,0,0                           
154         .byte   3,3,2,2                           
155         .byte   3,2,2,3                           
156         .byte   2,3,3,2                           
157                                                   
158         |xref   binstr                            
159         |xref   sintdo                            
160         |xref   ptenrn,ptenrm,ptenrp              
161                                                   
162         .global bindec                            
163         .global sc_mul                            
164 bindec:                                           
165         moveml  %d2-%d7/%a2,-(%a7)                
166         fmovemx %fp0-%fp2,-(%a7)                  
167                                                   
168 | A1. Set RM and size ext. Set SIGMA = sign in    
169 |     The k-factor is saved for use in d7.  Cl    
170 |     separating  normalized/denormalized inpu    
171 |     is a denormalized number, set the BINDEC    
172 |     to signal denorm.  If the input is unnor    
173 |     the input and test for denormalized resu    
174 |                                                 
175         fmovel  #rm_mode,%FPCR  |set RM and ex    
176         movel   (%a0),L_SCR2(%a6)       |save     
177         movel   %d0,%d7         |move k-factor    
178         clrb    BINDEC_FLG(%a6) |clr norm/deno    
179         movew   STAG(%a6),%d0   |get stag         
180         andiw   #0xe000,%d0     |isolate stag     
181         beq     A2_str          |if zero, inpu    
182 |                                                 
183 | Normalize the denorm                            
184 |                                                 
185 un_de_norm:                                       
186         movew   (%a0),%d0                         
187         andiw   #0x7fff,%d0     |strip sign of    
188         movel   4(%a0),%d1                        
189         movel   8(%a0),%d2                        
190 norm_loop:                                        
191         subw    #1,%d0                            
192         lsll    #1,%d2                            
193         roxll   #1,%d1                            
194         tstl    %d1                               
195         bges    norm_loop                         
196 |                                                 
197 | Test if the normalized input is denormalized    
198 |                                                 
199         tstw    %d0                               
200         bgts    pos_exp         |if greater th    
201         st      BINDEC_FLG(%a6) |set flag for     
202 pos_exp:                                          
203         andiw   #0x7fff,%d0     |strip sign of    
204         movew   %d0,(%a0)                         
205         movel   %d1,4(%a0)                        
206         movel   %d2,8(%a0)                        
207                                                   
208 | A2. Set X = abs(input).                         
209 |                                                 
210 A2_str:                                           
211         movel   (%a0),FP_SCR2(%a6) | move inpu    
212         movel   4(%a0),FP_SCR2+4(%a6) | move i    
213         movel   8(%a0),FP_SCR2+8(%a6) | move i    
214         andil   #0x7fffffff,FP_SCR2(%a6) |crea    
215                                                   
216 | A3. Compute ILOG.                               
217 |     ILOG is the log base 10 of the input val    
218 |     imated by adding e + 0.f when the origin    
219 |     as 2^^e * 1.f in extended precision.  Th    
220 |     in d6.                                      
221 |                                                 
222 | Register usage:                                 
223 |       Input/Output                              
224 |       d0: k-factor/exponent                     
225 |       d2: x/x                                   
226 |       d3: x/x                                   
227 |       d4: x/x                                   
228 |       d5: x/x                                   
229 |       d6: x/ILOG                                
230 |       d7: k-factor/Unchanged                    
231 |       a0: ptr for original operand/final res    
232 |       a1: x/x                                   
233 |       a2: x/x                                   
234 |       fp0: x/float(ILOG)                        
235 |       fp1: x/x                                  
236 |       fp2: x/x                                  
237 |       F_SCR1:x/x                                
238 |       F_SCR2:Abs(X)/Abs(X) with $3fff expone    
239 |       L_SCR1:x/x                                
240 |       L_SCR2:first word of X packed/Unchange    
241                                                   
242         tstb    BINDEC_FLG(%a6) |check for den    
243         beqs    A3_cont         |if clr, conti    
244         movel   #-4933,%d6      |force ILOG =     
245         bras    A4_str                            
246 A3_cont:                                          
247         movew   FP_SCR2(%a6),%d0        |move     
248         movew   #0x3fff,FP_SCR2(%a6) |replace     
249         fmovex  FP_SCR2(%a6),%fp0       |now f    
250         subw    #0x3fff,%d0     |strip off bia    
251         faddw   %d0,%fp0                |add i    
252         fsubs   FONE,%fp0       |subtract off     
253         fbge    pos_res         |if pos, branc    
254         fmulx   LOG2UP1,%fp0    |if neg, mul b    
255         fmovel  %fp0,%d6                |put I    
256         bras    A4_str          |go move out I    
257 pos_res:                                          
258         fmulx   LOG2,%fp0       |if pos, mul b    
259         fmovel  %fp0,%d6                |put I    
260                                                   
261                                                   
262 | A4. Clr INEX bit.                               
263 |     The operation in A3 above may have set I    
264                                                   
265 A4_str:                                           
266         fmovel  #0,%FPSR                |zero     
267                                                   
268                                                   
269 | A5. Set ICTR = 0;                               
270 |     ICTR is a flag used in A13.  It must be     
271 |     loop entry A6. The lower word of d5 is u    
272                                                   
273         clrw    %d5             |clear ICTR       
274                                                   
275                                                   
276 | A6. Calculate LEN.                              
277 |     LEN is the number of digits to be displa    
278 |     can dictate either the total number of d    
279 |     a positive number, or the number of digi    
280 |     original decimal point which are to be i    
281 |     significant.  See the 68882 manual for e    
282 |     If LEN is computed to be greater than 17    
283 |     USER_FPSR.  LEN is stored in d4.            
284 |                                                 
285 | Register usage:                                 
286 |       Input/Output                              
287 |       d0: exponent/Unchanged                    
288 |       d2: x/x/scratch                           
289 |       d3: x/x                                   
290 |       d4: exc picture/LEN                       
291 |       d5: ICTR/Unchanged                        
292 |       d6: ILOG/Unchanged                        
293 |       d7: k-factor/Unchanged                    
294 |       a0: ptr for original operand/final res    
295 |       a1: x/x                                   
296 |       a2: x/x                                   
297 |       fp0: float(ILOG)/Unchanged                
298 |       fp1: x/x                                  
299 |       fp2: x/x                                  
300 |       F_SCR1:x/x                                
301 |       F_SCR2:Abs(X) with $3fff exponent/Unch    
302 |       L_SCR1:x/x                                
303 |       L_SCR2:first word of X packed/Unchange    
304                                                   
305 A6_str:                                           
306         tstl    %d7             |branch on sig    
307         bles    k_neg           |if k <= 0, LE    
308         movel   %d7,%d4         |if k > 0, LEN    
309         bras    len_ck          |skip to LEN c    
310 k_neg:                                            
311         movel   %d6,%d4         |first load IL    
312         subl    %d7,%d4         |subtract off     
313         addql   #1,%d4          |add in the 1     
314 len_ck:                                           
315         tstl    %d4             |LEN check: br    
316         bles    LEN_ng          |if neg, set L    
317         cmpl    #17,%d4         |test if LEN >    
318         bles    A7_str          |if not, forge    
319         movel   #17,%d4         |set max LEN =    
320         tstl    %d7             |if negative,     
321         bles    A7_str          |if positive,     
322         orl     #opaop_mask,USER_FPSR(%a6) |se    
323         bras    A7_str          |finished here    
324 LEN_ng:                                           
325         moveql  #1,%d4          |min LEN is 1     
326                                                   
327                                                   
328 | A7. Calculate SCALE.                            
329 |     SCALE is equal to 10^ISCALE, where ISCAL    
330 |     of decimal places needed to insure LEN i    
331 |     in the output before conversion to bcd.     
332 |     of ISCALE, used in A9.  Fp1 contains 10^    
333 |     the rounding mode as given in the follow    
334 |     Coonen, p. 7.23 as ref.; however, the SC    
335 |     of opposite sign in bindec.sa from Coone    
336 |                                                 
337 |       Initial                                   
338 |       FPCR[6:5]       LAMBDA  SIGN(X)           
339 |       --------------------------------------    
340 |        RN     00         0       0              
341 |        RN     00         0       1              
342 |        RN     00         1       0              
343 |        RN     00         1       1              
344 |        RZ     01         0       0              
345 |        RZ     01         0       1              
346 |        RZ     01         1       0              
347 |        RZ     01         1       1              
348 |        RM     10         0       0              
349 |        RM     10         0       1              
350 |        RM     10         1       0              
351 |        RM     10         1       1              
352 |        RP     11         0       0              
353 |        RP     11         0       1              
354 |        RP     11         1       0              
355 |        RP     11         1       1              
356 |                                                 
357 | Register usage:                                 
358 |       Input/Output                              
359 |       d0: exponent/scratch - final is 0         
360 |       d2: x/0 or 24 for A9                      
361 |       d3: x/scratch - offset ptr into PTENRM    
362 |       d4: LEN/Unchanged                         
363 |       d5: 0/ICTR:LAMBDA                         
364 |       d6: ILOG/ILOG or k if ((k<=0)&(ILOG<k)    
365 |       d7: k-factor/Unchanged                    
366 |       a0: ptr for original operand/final res    
367 |       a1: x/ptr to PTENRM array                 
368 |       a2: x/x                                   
369 |       fp0: float(ILOG)/Unchanged                
370 |       fp1: x/10^ISCALE                          
371 |       fp2: x/x                                  
372 |       F_SCR1:x/x                                
373 |       F_SCR2:Abs(X) with $3fff exponent/Unch    
374 |       L_SCR1:x/x                                
375 |       L_SCR2:first word of X packed/Unchange    
376                                                   
377 A7_str:                                           
378         tstl    %d7             |test sign of     
379         bgts    k_pos           |if pos and >     
380         cmpl    %d6,%d7         |test k - ILOG    
381         blts    k_pos           |if ILOG >= k,    
382         movel   %d7,%d6         |if ((k<0) & (    
383 k_pos:                                            
384         movel   %d6,%d0         |calc ILOG + 1    
385         addql   #1,%d0          |add the 1        
386         subl    %d4,%d0         |sub off LEN      
387         swap    %d5             |use upper wor    
388         clrw    %d5             |set it zero i    
389         clrw    %d2             |set up d2 for    
390         tstl    %d0             |test sign of     
391         bges    iscale          |if pos, skip     
392         addqw   #1,%d5          |if neg, set L    
393         cmpl    #0xffffecd4,%d0 |test iscale <    
394         bgts    no_inf          |if false, ski    
395         addil   #24,%d0         |add in 24 to     
396         movel   #24,%d2         |put 24 in d2     
397 no_inf:                                           
398         negl    %d0             |and take abs     
399 iscale:                                           
400         fmoves  FONE,%fp1       |init fp1 to 1    
401         bfextu  USER_FPCR(%a6){#26:#2},%d1 |ge    
402         lslw    #1,%d1          |put them in b    
403         addw    %d5,%d1         |add in LAMBDA    
404         lslw    #1,%d1          |put them in b    
405         tstl    L_SCR2(%a6)     |test sign of     
406         bges    x_pos           |if pos, don't    
407         addql   #1,%d1          |if neg, set b    
408 x_pos:                                            
409         leal    RBDTBL,%a2      |load rbdtbl b    
410         moveb   (%a2,%d1),%d3   |load d3 with     
411         lsll    #4,%d3          |put bits in p    
412         fmovel  %d3,%fpcr               |load     
413         lsrl    #4,%d3          |put bits in p    
414         tstb    %d3             |decode new rm    
415         bnes    not_rn          |if zero, it i    
416         leal    PTENRN,%a1      |load a1 with     
417         bras    rmode           |exit decode      
418 not_rn:                                           
419         lsrb    #1,%d3          |get lsb in ca    
420         bccs    not_rp          |if carry clea    
421         leal    PTENRP,%a1      |load a1 with     
422         bras    rmode           |exit decode      
423 not_rp:                                           
424         leal    PTENRM,%a1      |load a1 with     
425 rmode:                                            
426         clrl    %d3             |clr table ind    
427 e_loop:                                           
428         lsrl    #1,%d0          |shift next bi    
429         bccs    e_next          |if zero, skip    
430         fmulx   (%a1,%d3),%fp1  |mul by 10**(d    
431 e_next:                                           
432         addl    #12,%d3         |inc d3 to nex    
433         tstl    %d0             |test if ISCAL    
434         bnes    e_loop          |if not, loop     
435                                                   
436                                                   
437 | A8. Clr INEX; Force RZ.                         
438 |     The operation in A3 above may have set I    
439 |     RZ mode is forced for the scaling operat    
440 |     only one rounding error.  The grs bits a    
441 |     the INEX flag for use in A10.               
442 |                                                 
443 | Register usage:                                 
444 |       Input/Output                              
445                                                   
446         fmovel  #0,%FPSR                |clr I    
447         fmovel  #rz_mode,%FPCR  |set RZ roundi    
448                                                   
449                                                   
450 | A9. Scale X -> Y.                               
451 |     The mantissa is scaled to the desired nu    
452 |     digits.  The excess digits are collected    
453 |     Check d2 for excess 10 exponential value    
454 |     the iscale value would have caused the p    
455 |     to overflow.  Only a negative iscale can    
456 |     multiply by 10^(d2), which is now only a    
457 |     with a multiply by 10^8 and 10^16, which    
458 |     10^24 is exact.  If the input was denorm    
459 |     create a busy stack frame with the mul c    
460 |     two operands, and allow the fpu to compl    
461 |                                                 
462 | Register usage:                                 
463 |       Input/Output                              
464 |       d0: FPCR with RZ mode/Unchanged           
465 |       d2: 0 or 24/unchanged                     
466 |       d3: x/x                                   
467 |       d4: LEN/Unchanged                         
468 |       d5: ICTR:LAMBDA                           
469 |       d6: ILOG/Unchanged                        
470 |       d7: k-factor/Unchanged                    
471 |       a0: ptr for original operand/final res    
472 |       a1: ptr to PTENRM array/Unchanged         
473 |       a2: x/x                                   
474 |       fp0: float(ILOG)/X adjusted for SCALE     
475 |       fp1: 10^ISCALE/Unchanged                  
476 |       fp2: x/x                                  
477 |       F_SCR1:x/x                                
478 |       F_SCR2:Abs(X) with $3fff exponent/Unch    
479 |       L_SCR1:x/x                                
480 |       L_SCR2:first word of X packed/Unchange    
481                                                   
482 A9_str:                                           
483         fmovex  (%a0),%fp0      |load X from m    
484         fabsx   %fp0            |use abs(X)       
485         tstw    %d5             |LAMBDA is in     
486         bne     sc_mul          |if neg (LAMBD    
487         fdivx   %fp1,%fp0               |calcu    
488         bras    A10_st          |branch to A10    
489                                                   
490 sc_mul:                                           
491         tstb    BINDEC_FLG(%a6) |check for den    
492         beqs    A9_norm         |if norm, cont    
493         fmovemx %fp1-%fp1,-(%a7)        |load     
494         movel   8(%a0),-(%a7)   |load FPTEMP w    
495         movel   4(%a0),-(%a7)                     
496         movel   (%a0),-(%a7)                      
497         movel   #18,%d3         |load count fo    
498 A9_loop:                                          
499         clrl    -(%a7)          |clear lword o    
500         dbf     %d3,A9_loop                       
501         moveb   VER_TMP(%a6),(%a7) |write curr    
502         moveb   #BUSY_SIZE-4,1(%a7) |write cur    
503         moveb   #0x10,0x44(%a7) |set fcefpte[1    
504         movew   #0x0023,0x40(%a7)       |load     
505         moveb   #0xfe,0x8(%a7)  |load all 1s t    
506         frestore (%a7)+         |restore frame    
507         fmulx   36(%a1),%fp0    |multiply fp0     
508         fmulx   48(%a1),%fp0    |multiply fp0     
509         bras    A10_st                            
510 A9_norm:                                          
511         tstw    %d2             |test for smal    
512         beqs    A9_con          |if zero, cont    
513         fmulx   36(%a1),%fp0    |multiply fp0     
514         fmulx   48(%a1),%fp0    |multiply fp0     
515 A9_con:                                           
516         fmulx   %fp1,%fp0               |calcu    
517                                                   
518                                                   
519 | A10. Or in INEX.                                
520 |      If INEX is set, round error occurred.      
521 |      for by 'or-ing' in the INEX2 flag to th    
522 |                                                 
523 | Register usage:                                 
524 |       Input/Output                              
525 |       d0: FPCR with RZ mode/FPSR with INEX2     
526 |       d2: x/x                                   
527 |       d3: x/x                                   
528 |       d4: LEN/Unchanged                         
529 |       d5: ICTR:LAMBDA                           
530 |       d6: ILOG/Unchanged                        
531 |       d7: k-factor/Unchanged                    
532 |       a0: ptr for original operand/final res    
533 |       a1: ptr to PTENxx array/Unchanged         
534 |       a2: x/ptr to FP_SCR2(a6)                  
535 |       fp0: Y/Y with lsb adjusted                
536 |       fp1: 10^ISCALE/Unchanged                  
537 |       fp2: x/x                                  
538                                                   
539 A10_st:                                           
540         fmovel  %FPSR,%d0               |get F    
541         fmovex  %fp0,FP_SCR2(%a6)       |move     
542         leal    FP_SCR2(%a6),%a2        |load     
543         btstl   #9,%d0          |check if INEX    
544         beqs    A11_st          |if clear, ski    
545         oril    #1,8(%a2)       |or in 1 to ls    
546         fmovex  FP_SCR2(%a6),%fp0       |write    
547                                                   
548                                                   
549 | A11. Restore original FPCR; set size ext.       
550 |      Perform FINT operation in the user's ro    
551 |      the size to extended.  The sintdo entry    
552 |      routine expects the FPCR value to be in    
553 |      mode and precision.  The original FPCR     
554                                                   
555 A11_st:                                           
556         movel   USER_FPCR(%a6),L_SCR1(%a6) |sa    
557         andil   #0x00000030,USER_FPCR(%a6) |se    
558 |                                       ;block    
559                                                   
560                                                   
561 | A12. Calculate YINT = FINT(Y) according to u    
562 |      The FPSP routine sintd0 is used.  The o    
563 |                                                 
564 | Register usage:                                 
565 |       Input/Output                              
566 |       d0: FPSR with AINEX cleared/FPCR with     
567 |       d2: x/x/scratch                           
568 |       d3: x/x                                   
569 |       d4: LEN/Unchanged                         
570 |       d5: ICTR:LAMBDA/Unchanged                 
571 |       d6: ILOG/Unchanged                        
572 |       d7: k-factor/Unchanged                    
573 |       a0: ptr for original operand/src ptr f    
574 |       a1: ptr to PTENxx array/Unchanged         
575 |       a2: ptr to FP_SCR2(a6)/Unchanged          
576 |       a6: temp pointer to FP_SCR2(a6) - orig    
577 |       fp0: Y/YINT                               
578 |       fp1: 10^ISCALE/Unchanged                  
579 |       fp2: x/x                                  
580 |       F_SCR1:x/x                                
581 |       F_SCR2:Y adjusted for inex/Y with orig    
582 |       L_SCR1:x/original USER_FPCR               
583 |       L_SCR2:first word of X packed/Unchange    
584                                                   
585 A12_st:                                           
586         moveml  %d0-%d1/%a0-%a1,-(%a7)  |save     
587         movel   L_SCR1(%a6),-(%a7)                
588         movel   L_SCR2(%a6),-(%a7)                
589         leal    FP_SCR2(%a6),%a0                  
590         fmovex  %fp0,(%a0)              |move     
591         tstl    L_SCR2(%a6)             |test     
592         bges    do_fint                 |if po    
593         orl     #0x80000000,(%a0)                 
594 do_fint:                                          
595         movel   USER_FPSR(%a6),-(%a7)             
596         bsr     sintdo                  |sint     
597         moveb   (%a7),USER_FPSR(%a6)              
598         addl    #4,%a7                            
599         movel   (%a7)+,L_SCR2(%a6)                
600         movel   (%a7)+,L_SCR1(%a6)                
601         moveml  (%a7)+,%d0-%d1/%a0-%a1  |resto    
602         movel   L_SCR2(%a6),FP_SCR2(%a6)          
603         movel   L_SCR1(%a6),USER_FPCR(%a6) |re    
604                                                   
605                                                   
606 | A13. Check for LEN digits.                      
607 |      If the int operation results in more th    
608 |      or less than LEN -1 digits, adjust ILOG    
609 |      A6.  This test occurs only on the first    
610 |      result is exactly 10^LEN, decrement ILO    
611 |      the mantissa by 10.  The calculation of    
612 |      be inexact, since all powers of ten up     
613 |      in extended precision, so the use of a     
614 |      table will introduce no error.             
615 |                                                 
616 |                                                 
617 | Register usage:                                 
618 |       Input/Output                              
619 |       d0: FPCR with size set to ext/scratch     
620 |       d2: x/x                                   
621 |       d3: x/scratch final = x                   
622 |       d4: LEN/LEN adjusted                      
623 |       d5: ICTR:LAMBDA/LAMBDA:ICTR               
624 |       d6: ILOG/ILOG adjusted                    
625 |       d7: k-factor/Unchanged                    
626 |       a0: pointer into memory for packed bcd    
627 |       a1: ptr to PTENxx array/Unchanged         
628 |       a2: ptr to FP_SCR2(a6)/Unchanged          
629 |       fp0: int portion of Y/abs(YINT) adjust    
630 |       fp1: 10^ISCALE/Unchanged                  
631 |       fp2: x/10^LEN                             
632 |       F_SCR1:x/x                                
633 |       F_SCR2:Y with original exponent/Unchan    
634 |       L_SCR1:original USER_FPCR/Unchanged       
635 |       L_SCR2:first word of X packed/Unchange    
636                                                   
637 A13_st:                                           
638         swap    %d5             |put ICTR in l    
639         tstw    %d5             |check if ICTR    
640         bne     not_zr          |if non-zero,     
641 |                                                 
642 | Compute 10^(LEN-1)                              
643 |                                                 
644         fmoves  FONE,%fp2       |init fp2 to 1    
645         movel   %d4,%d0         |put LEN in d0    
646         subql   #1,%d0          |d0 = LEN -1      
647         clrl    %d3             |clr table ind    
648 l_loop:                                           
649         lsrl    #1,%d0          |shift next bi    
650         bccs    l_next          |if zero, skip    
651         fmulx   (%a1,%d3),%fp2  |mul by 10**(d    
652 l_next:                                           
653         addl    #12,%d3         |inc d3 to nex    
654         tstl    %d0             |test if LEN i    
655         bnes    l_loop          |if not, loop     
656 |                                                 
657 | 10^LEN-1 is computed for this test and A14.     
658 | denormalized, check only the case in which Y    
659 |                                                 
660         tstb    BINDEC_FLG(%a6) |check if inpu    
661         beqs    A13_con         |if norm, cont    
662         fabsx   %fp0            |take abs of Y    
663         bra     test_2                            
664 |                                                 
665 | Compare abs(YINT) to 10^(LEN-1) and 10^LEN      
666 |                                                 
667 A13_con:                                          
668         fabsx   %fp0            |take abs of Y    
669         fcmpx   %fp2,%fp0               |compa    
670         fbge    test_2          |if greater, d    
671         subql   #1,%d6          |subtract 1 fr    
672         movew   #1,%d5          |set ICTR         
673         fmovel  #rm_mode,%FPCR  |set rmode to     
674         fmuls   FTEN,%fp2       |compute 10^LE    
675         bra     A6_str          |return to A6     
676 test_2:                                           
677         fmuls   FTEN,%fp2       |compute 10^LE    
678         fcmpx   %fp2,%fp0               |compa    
679         fblt    A14_st          |if less, all     
680         fbgt    fix_ex          |if greater, f    
681         fdivs   FTEN,%fp0       |if equal, div    
682         addql   #1,%d6          | and inc ILOG    
683         bras    A14_st          | and continue    
684 fix_ex:                                           
685         addql   #1,%d6          |increment ILO    
686         movew   #1,%d5          |set ICTR         
687         fmovel  #rm_mode,%FPCR  |set rmode to     
688         bra     A6_str          |return to A6     
689 |                                                 
690 | Since ICTR <> 0, we have already been throug    
691 | and shouldn't have another; this is to check    
692 | 10^LEN is again computed using whatever tabl    
693 | value calculated cannot be inexact.             
694 |                                                 
695 not_zr:                                           
696         fmoves  FONE,%fp2       |init fp2 to 1    
697         movel   %d4,%d0         |put LEN in d0    
698         clrl    %d3             |clr table ind    
699 z_loop:                                           
700         lsrl    #1,%d0          |shift next bi    
701         bccs    z_next          |if zero, skip    
702         fmulx   (%a1,%d3),%fp2  |mul by 10**(d    
703 z_next:                                           
704         addl    #12,%d3         |inc d3 to nex    
705         tstl    %d0             |test if LEN i    
706         bnes    z_loop          |if not, loop     
707         fabsx   %fp0            |get abs(YINT)    
708         fcmpx   %fp2,%fp0               |check    
709         fbne    A14_st          |if not, skip     
710         fdivs   FTEN,%fp0       |divide abs(YI    
711         addql   #1,%d6          |and inc ILOG     
712         addql   #1,%d4          | and inc LEN     
713         fmuls   FTEN,%fp2       | if LEN++, th    
714                                                   
715                                                   
716 | A14. Convert the mantissa to bcd.               
717 |      The binstr routine is used to convert t    
718 |      mantissa to bcd in memory.  The input t    
719 |      to be a fraction; i.e. (mantissa)/10^LE    
720 |      such that the decimal point is to the l    
721 |      The bcd digits are stored in the correc    
722 |      the final string area in memory.           
723 |                                                 
724 |                                                 
725 | Register usage:                                 
726 |       Input/Output                              
727 |       d0: x/LEN call to binstr - final is 0     
728 |       d1: x/0                                   
729 |       d2: x/ms 32-bits of mant of abs(YINT)     
730 |       d3: x/ls 32-bits of mant of abs(YINT)     
731 |       d4: LEN/Unchanged                         
732 |       d5: ICTR:LAMBDA/LAMBDA:ICTR               
733 |       d6: ILOG                                  
734 |       d7: k-factor/Unchanged                    
735 |       a0: pointer into memory for packed bcd    
736 |           /ptr to first mantissa byte in res    
737 |       a1: ptr to PTENxx array/Unchanged         
738 |       a2: ptr to FP_SCR2(a6)/Unchanged          
739 |       fp0: int portion of Y/abs(YINT) adjust    
740 |       fp1: 10^ISCALE/Unchanged                  
741 |       fp2: 10^LEN/Unchanged                     
742 |       F_SCR1:x/Work area for final result       
743 |       F_SCR2:Y with original exponent/Unchan    
744 |       L_SCR1:original USER_FPCR/Unchanged       
745 |       L_SCR2:first word of X packed/Unchange    
746                                                   
747 A14_st:                                           
748         fmovel  #rz_mode,%FPCR  |force rz for     
749         fdivx   %fp2,%fp0               |divid    
750         leal    FP_SCR1(%a6),%a0                  
751         fmovex  %fp0,(%a0)      |move abs(YINT    
752         movel   4(%a0),%d2      |move 2nd word    
753         movel   8(%a0),%d3      |move 3rd word    
754         clrl    4(%a0)          |zero word 2 o    
755         clrl    8(%a0)          |zero word 3 o    
756         movel   (%a0),%d0               |move     
757         swap    %d0             |put exponent     
758         beqs    no_sft          |if zero, don'    
759         subil   #0x3ffd,%d0     |sub bias less    
760         tstl    %d0             |check if > 1     
761         bgts    no_sft          |if so, don't     
762         negl    %d0             |make exp posi    
763 m_loop:                                           
764         lsrl    #1,%d2          |shift d2:d3 r    
765         roxrl   #1,%d3          |the number of    
766         dbf     %d0,m_loop      |given in d0      
767 no_sft:                                           
768         tstl    %d2             |check for man    
769         bnes    no_zr           |if not, go on    
770         tstl    %d3             |continue zero    
771         beqs    zer_m           |if zero, go d    
772 no_zr:                                            
773         clrl    %d1             |put zero in d    
774         addil   #0x00000080,%d3 |inc at bit 7     
775         addxl   %d1,%d2         |continue inc     
776         andil   #0xffffff80,%d3 |strip off lsb    
777 zer_m:                                            
778         movel   %d4,%d0         |put LEN in d0    
779         addql   #3,%a0          |a0 points to     
780         bsr     binstr          |call binstr t    
781                                                   
782                                                   
783 | A15. Convert the exponent to bcd.               
784 |      As in A14 above, the exp is converted t    
785 |      digits are stored in the final string.     
786 |                                                 
787 |      Digits are stored in L_SCR1(a6) on retu    
788 |                                                 
789 |        32               16 15                   
790 |       --------------------------------------    
791 |       |  0 | e3 | e2 | e1 | e4 |  X |  X |      
792 |       --------------------------------------    
793 |                                                 
794 | And are moved into their proper places in FP    
795 | is non-zero, OPERR is signaled.  In all case    
796 | written as specified in the 881/882 manual f    
797 |                                                 
798 | Register usage:                                 
799 |       Input/Output                              
800 |       d0: x/LEN call to binstr - final is 0     
801 |       d1: x/scratch (0);shift count for fina    
802 |       d2: x/ms 32-bits of exp fraction/scrat    
803 |       d3: x/ls 32-bits of exp fraction          
804 |       d4: LEN/Unchanged                         
805 |       d5: ICTR:LAMBDA/LAMBDA:ICTR               
806 |       d6: ILOG                                  
807 |       d7: k-factor/Unchanged                    
808 |       a0: ptr to result string/ptr to L_SCR1    
809 |       a1: ptr to PTENxx array/Unchanged         
810 |       a2: ptr to FP_SCR2(a6)/Unchanged          
811 |       fp0: abs(YINT) adjusted/float(ILOG)       
812 |       fp1: 10^ISCALE/Unchanged                  
813 |       fp2: 10^LEN/Unchanged                     
814 |       F_SCR1:Work area for final result/BCD     
815 |       F_SCR2:Y with original exponent/ILOG/1    
816 |       L_SCR1:original USER_FPCR/Exponent dig    
817 |       L_SCR2:first word of X packed/Unchange    
818                                                   
819 A15_st:                                           
820         tstb    BINDEC_FLG(%a6) |check for den    
821         beqs    not_denorm                        
822         ftstx   %fp0            |test for zero    
823         fbeq    den_zero        |if zero, use     
824         fmovel  %d6,%fp0                |float    
825         fabsx   %fp0            |get abs of IL    
826         bras    convrt                            
827 den_zero:                                         
828         tstl    %d7             |check sign of    
829         blts    use_ilog        |if negative,     
830         fmoves  F4933,%fp0      |force exponen    
831         bras    convrt          |do it            
832 use_ilog:                                         
833         fmovel  %d6,%fp0                |float    
834         fabsx   %fp0            |get abs of IL    
835         bras    convrt                            
836 not_denorm:                                       
837         ftstx   %fp0            |test for zero    
838         fbne    not_zero        |if zero, forc    
839         fmoves  FONE,%fp0       |force exponen    
840         bras    convrt          |do it            
841 not_zero:                                         
842         fmovel  %d6,%fp0                |float    
843         fabsx   %fp0            |get abs of IL    
844 convrt:                                           
845         fdivx   24(%a1),%fp0    |compute ILOG/    
846         fmovex  %fp0,FP_SCR2(%a6)       |store    
847         movel   4(%a2),%d2      |move word 2 t    
848         movel   8(%a2),%d3      |move word 3 t    
849         movew   (%a2),%d0               |move     
850         beqs    x_loop_fin      |if zero, skip    
851         subiw   #0x3ffd,%d0     |subtract off     
852         negw    %d0             |make exp posi    
853 x_loop:                                           
854         lsrl    #1,%d2          |shift d2:d3 r    
855         roxrl   #1,%d3          |the number of    
856         dbf     %d0,x_loop      |given in d0      
857 x_loop_fin:                                       
858         clrl    %d1             |put zero in d    
859         addil   #0x00000080,%d3 |inc at bit 6     
860         addxl   %d1,%d2         |continue inc     
861         andil   #0xffffff80,%d3 |strip off lsb    
862         movel   #4,%d0          |put 4 in d0 f    
863         leal    L_SCR1(%a6),%a0 |a0 is ptr to     
864         bsr     binstr          |call binstr t    
865         movel   L_SCR1(%a6),%d0 |load L_SCR1 l    
866         movel   #12,%d1         |use d1 for sh    
867         lsrl    %d1,%d0         |shift d0 righ    
868         bfins   %d0,FP_SCR1(%a6){#4:#12} |put     
869         lsrl    %d1,%d0         |shift d0 righ    
870         bfins   %d0,FP_SCR1(%a6){#16:#4} |put     
871         tstb    %d0             |check if e4 i    
872         beqs    A16_st          |if zero, skip    
873         orl     #opaop_mask,USER_FPSR(%a6) |se    
874                                                   
875                                                   
876 | A16. Write sign bits to final string.           
877 |          Sigma is bit 31 of initial value; R    
878 |                                                 
879 | Register usage:                                 
880 |       Input/Output                              
881 |       d0: x/scratch - final is x                
882 |       d2: x/x                                   
883 |       d3: x/x                                   
884 |       d4: LEN/Unchanged                         
885 |       d5: ICTR:LAMBDA/LAMBDA:ICTR               
886 |       d6: ILOG/ILOG adjusted                    
887 |       d7: k-factor/Unchanged                    
888 |       a0: ptr to L_SCR1(a6)/Unchanged           
889 |       a1: ptr to PTENxx array/Unchanged         
890 |       a2: ptr to FP_SCR2(a6)/Unchanged          
891 |       fp0: float(ILOG)/Unchanged                
892 |       fp1: 10^ISCALE/Unchanged                  
893 |       fp2: 10^LEN/Unchanged                     
894 |       F_SCR1:BCD result with correct signs      
895 |       F_SCR2:ILOG/10^4                          
896 |       L_SCR1:Exponent digits on return from     
897 |       L_SCR2:first word of X packed/Unchange    
898                                                   
899 A16_st:                                           
900         clrl    %d0             |clr d0 for co    
901         andib   #0x0f,FP_SCR1(%a6) |clear firs    
902         tstl    L_SCR2(%a6)     |check sign of    
903         bges    mant_p          |if pos, don't    
904         moveql  #2,%d0          |move 2 in to     
905 mant_p:                                           
906         tstl    %d6             |check sign of    
907         bges    wr_sgn          |if pos, don't    
908         addql   #1,%d0          |set bit 0 in     
909 wr_sgn:                                           
910         bfins   %d0,FP_SCR1(%a6){#0:#2} |inser    
911                                                   
912 | Clean up and restore all registers used.        
913                                                   
914         fmovel  #0,%FPSR                |clear    
915         fmovemx (%a7)+,%fp0-%fp2                  
916         moveml  (%a7)+,%d2-%d7/%a2                
917         rts                                       
918                                                   
919         |end                                      
                                                      

~ [ 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