18c2ecf20Sopenharmony_ci| 28c2ecf20Sopenharmony_ci| bindec.sa 3.4 1/3/91 38c2ecf20Sopenharmony_ci| 48c2ecf20Sopenharmony_ci| bindec 58c2ecf20Sopenharmony_ci| 68c2ecf20Sopenharmony_ci| Description: 78c2ecf20Sopenharmony_ci| Converts an input in extended precision format 88c2ecf20Sopenharmony_ci| to bcd format. 98c2ecf20Sopenharmony_ci| 108c2ecf20Sopenharmony_ci| Input: 118c2ecf20Sopenharmony_ci| a0 points to the input extended precision value 128c2ecf20Sopenharmony_ci| value in memory; d0 contains the k-factor sign-extended 138c2ecf20Sopenharmony_ci| to 32-bits. The input may be either normalized, 148c2ecf20Sopenharmony_ci| unnormalized, or denormalized. 158c2ecf20Sopenharmony_ci| 168c2ecf20Sopenharmony_ci| Output: result in the FP_SCR1 space on the stack. 178c2ecf20Sopenharmony_ci| 188c2ecf20Sopenharmony_ci| Saves and Modifies: D2-D7,A2,FP2 198c2ecf20Sopenharmony_ci| 208c2ecf20Sopenharmony_ci| Algorithm: 218c2ecf20Sopenharmony_ci| 228c2ecf20Sopenharmony_ci| A1. Set RM and size ext; Set SIGMA = sign of input. 238c2ecf20Sopenharmony_ci| The k-factor is saved for use in d7. Clear the 248c2ecf20Sopenharmony_ci| BINDEC_FLG for separating normalized/denormalized 258c2ecf20Sopenharmony_ci| input. If input is unnormalized or denormalized, 268c2ecf20Sopenharmony_ci| normalize it. 278c2ecf20Sopenharmony_ci| 288c2ecf20Sopenharmony_ci| A2. Set X = abs(input). 298c2ecf20Sopenharmony_ci| 308c2ecf20Sopenharmony_ci| A3. Compute ILOG. 318c2ecf20Sopenharmony_ci| ILOG is the log base 10 of the input value. It is 328c2ecf20Sopenharmony_ci| approximated by adding e + 0.f when the original 338c2ecf20Sopenharmony_ci| value is viewed as 2^^e * 1.f in extended precision. 348c2ecf20Sopenharmony_ci| This value is stored in d6. 358c2ecf20Sopenharmony_ci| 368c2ecf20Sopenharmony_ci| A4. Clr INEX bit. 378c2ecf20Sopenharmony_ci| The operation in A3 above may have set INEX2. 388c2ecf20Sopenharmony_ci| 398c2ecf20Sopenharmony_ci| A5. Set ICTR = 0; 408c2ecf20Sopenharmony_ci| ICTR is a flag used in A13. It must be set before the 418c2ecf20Sopenharmony_ci| loop entry A6. 428c2ecf20Sopenharmony_ci| 438c2ecf20Sopenharmony_ci| A6. Calculate LEN. 448c2ecf20Sopenharmony_ci| LEN is the number of digits to be displayed. The 458c2ecf20Sopenharmony_ci| k-factor can dictate either the total number of digits, 468c2ecf20Sopenharmony_ci| if it is a positive number, or the number of digits 478c2ecf20Sopenharmony_ci| after the decimal point which are to be included as 488c2ecf20Sopenharmony_ci| significant. See the 68882 manual for examples. 498c2ecf20Sopenharmony_ci| If LEN is computed to be greater than 17, set OPERR in 508c2ecf20Sopenharmony_ci| USER_FPSR. LEN is stored in d4. 518c2ecf20Sopenharmony_ci| 528c2ecf20Sopenharmony_ci| A7. Calculate SCALE. 538c2ecf20Sopenharmony_ci| SCALE is equal to 10^ISCALE, where ISCALE is the number 548c2ecf20Sopenharmony_ci| of decimal places needed to insure LEN integer digits 558c2ecf20Sopenharmony_ci| in the output before conversion to bcd. LAMBDA is the 568c2ecf20Sopenharmony_ci| sign of ISCALE, used in A9. Fp1 contains 578c2ecf20Sopenharmony_ci| 10^^(abs(ISCALE)) using a rounding mode which is a 588c2ecf20Sopenharmony_ci| function of the original rounding mode and the signs 598c2ecf20Sopenharmony_ci| of ISCALE and X. A table is given in the code. 608c2ecf20Sopenharmony_ci| 618c2ecf20Sopenharmony_ci| A8. Clr INEX; Force RZ. 628c2ecf20Sopenharmony_ci| The operation in A3 above may have set INEX2. 638c2ecf20Sopenharmony_ci| RZ mode is forced for the scaling operation to insure 648c2ecf20Sopenharmony_ci| only one rounding error. The grs bits are collected in 658c2ecf20Sopenharmony_ci| the INEX flag for use in A10. 668c2ecf20Sopenharmony_ci| 678c2ecf20Sopenharmony_ci| A9. Scale X -> Y. 688c2ecf20Sopenharmony_ci| The mantissa is scaled to the desired number of 698c2ecf20Sopenharmony_ci| significant digits. The excess digits are collected 708c2ecf20Sopenharmony_ci| in INEX2. 718c2ecf20Sopenharmony_ci| 728c2ecf20Sopenharmony_ci| A10. Or in INEX. 738c2ecf20Sopenharmony_ci| If INEX is set, round error occurred. This is 748c2ecf20Sopenharmony_ci| compensated for by 'or-ing' in the INEX2 flag to 758c2ecf20Sopenharmony_ci| the lsb of Y. 768c2ecf20Sopenharmony_ci| 778c2ecf20Sopenharmony_ci| A11. Restore original FPCR; set size ext. 788c2ecf20Sopenharmony_ci| Perform FINT operation in the user's rounding mode. 798c2ecf20Sopenharmony_ci| Keep the size to extended. 808c2ecf20Sopenharmony_ci| 818c2ecf20Sopenharmony_ci| A12. Calculate YINT = FINT(Y) according to user's rounding 828c2ecf20Sopenharmony_ci| mode. The FPSP routine sintd0 is used. The output 838c2ecf20Sopenharmony_ci| is in fp0. 848c2ecf20Sopenharmony_ci| 858c2ecf20Sopenharmony_ci| A13. Check for LEN digits. 868c2ecf20Sopenharmony_ci| If the int operation results in more than LEN digits, 878c2ecf20Sopenharmony_ci| or less than LEN -1 digits, adjust ILOG and repeat from 888c2ecf20Sopenharmony_ci| A6. This test occurs only on the first pass. If the 898c2ecf20Sopenharmony_ci| result is exactly 10^LEN, decrement ILOG and divide 908c2ecf20Sopenharmony_ci| the mantissa by 10. 918c2ecf20Sopenharmony_ci| 928c2ecf20Sopenharmony_ci| A14. Convert the mantissa to bcd. 938c2ecf20Sopenharmony_ci| The binstr routine is used to convert the LEN digit 948c2ecf20Sopenharmony_ci| mantissa to bcd in memory. The input to binstr is 958c2ecf20Sopenharmony_ci| to be a fraction; i.e. (mantissa)/10^LEN and adjusted 968c2ecf20Sopenharmony_ci| such that the decimal point is to the left of bit 63. 978c2ecf20Sopenharmony_ci| The bcd digits are stored in the correct position in 988c2ecf20Sopenharmony_ci| the final string area in memory. 998c2ecf20Sopenharmony_ci| 1008c2ecf20Sopenharmony_ci| A15. Convert the exponent to bcd. 1018c2ecf20Sopenharmony_ci| As in A14 above, the exp is converted to bcd and the 1028c2ecf20Sopenharmony_ci| digits are stored in the final string. 1038c2ecf20Sopenharmony_ci| Test the length of the final exponent string. If the 1048c2ecf20Sopenharmony_ci| length is 4, set operr. 1058c2ecf20Sopenharmony_ci| 1068c2ecf20Sopenharmony_ci| A16. Write sign bits to final string. 1078c2ecf20Sopenharmony_ci| 1088c2ecf20Sopenharmony_ci| Implementation Notes: 1098c2ecf20Sopenharmony_ci| 1108c2ecf20Sopenharmony_ci| The registers are used as follows: 1118c2ecf20Sopenharmony_ci| 1128c2ecf20Sopenharmony_ci| d0: scratch; LEN input to binstr 1138c2ecf20Sopenharmony_ci| d1: scratch 1148c2ecf20Sopenharmony_ci| d2: upper 32-bits of mantissa for binstr 1158c2ecf20Sopenharmony_ci| d3: scratch;lower 32-bits of mantissa for binstr 1168c2ecf20Sopenharmony_ci| d4: LEN 1178c2ecf20Sopenharmony_ci| d5: LAMBDA/ICTR 1188c2ecf20Sopenharmony_ci| d6: ILOG 1198c2ecf20Sopenharmony_ci| d7: k-factor 1208c2ecf20Sopenharmony_ci| a0: ptr for original operand/final result 1218c2ecf20Sopenharmony_ci| a1: scratch pointer 1228c2ecf20Sopenharmony_ci| a2: pointer to FP_X; abs(original value) in ext 1238c2ecf20Sopenharmony_ci| fp0: scratch 1248c2ecf20Sopenharmony_ci| fp1: scratch 1258c2ecf20Sopenharmony_ci| fp2: scratch 1268c2ecf20Sopenharmony_ci| F_SCR1: 1278c2ecf20Sopenharmony_ci| F_SCR2: 1288c2ecf20Sopenharmony_ci| L_SCR1: 1298c2ecf20Sopenharmony_ci| L_SCR2: 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci| Copyright (C) Motorola, Inc. 1990 1328c2ecf20Sopenharmony_ci| All Rights Reserved 1338c2ecf20Sopenharmony_ci| 1348c2ecf20Sopenharmony_ci| For details on the license for this file, please see the 1358c2ecf20Sopenharmony_ci| file, README, in this same directory. 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci|BINDEC idnt 2,1 | Motorola 040 Floating Point Software Package 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci#include "fpsp.h" 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci |section 8 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci| Constants in extended precision 1448c2ecf20Sopenharmony_ciLOG2: .long 0x3FFD0000,0x9A209A84,0xFBCFF798,0x00000000 1458c2ecf20Sopenharmony_ciLOG2UP1: .long 0x3FFD0000,0x9A209A84,0xFBCFF799,0x00000000 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci| Constants in single precision 1488c2ecf20Sopenharmony_ciFONE: .long 0x3F800000,0x00000000,0x00000000,0x00000000 1498c2ecf20Sopenharmony_ciFTWO: .long 0x40000000,0x00000000,0x00000000,0x00000000 1508c2ecf20Sopenharmony_ciFTEN: .long 0x41200000,0x00000000,0x00000000,0x00000000 1518c2ecf20Sopenharmony_ciF4933: .long 0x459A2800,0x00000000,0x00000000,0x00000000 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ciRBDTBL: .byte 0,0,0,0 1548c2ecf20Sopenharmony_ci .byte 3,3,2,2 1558c2ecf20Sopenharmony_ci .byte 3,2,2,3 1568c2ecf20Sopenharmony_ci .byte 2,3,3,2 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci |xref binstr 1598c2ecf20Sopenharmony_ci |xref sintdo 1608c2ecf20Sopenharmony_ci |xref ptenrn,ptenrm,ptenrp 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci .global bindec 1638c2ecf20Sopenharmony_ci .global sc_mul 1648c2ecf20Sopenharmony_cibindec: 1658c2ecf20Sopenharmony_ci moveml %d2-%d7/%a2,-(%a7) 1668c2ecf20Sopenharmony_ci fmovemx %fp0-%fp2,-(%a7) 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci| A1. Set RM and size ext. Set SIGMA = sign input; 1698c2ecf20Sopenharmony_ci| The k-factor is saved for use in d7. Clear BINDEC_FLG for 1708c2ecf20Sopenharmony_ci| separating normalized/denormalized input. If the input 1718c2ecf20Sopenharmony_ci| is a denormalized number, set the BINDEC_FLG memory word 1728c2ecf20Sopenharmony_ci| to signal denorm. If the input is unnormalized, normalize 1738c2ecf20Sopenharmony_ci| the input and test for denormalized result. 1748c2ecf20Sopenharmony_ci| 1758c2ecf20Sopenharmony_ci fmovel #rm_mode,%FPCR |set RM and ext 1768c2ecf20Sopenharmony_ci movel (%a0),L_SCR2(%a6) |save exponent for sign check 1778c2ecf20Sopenharmony_ci movel %d0,%d7 |move k-factor to d7 1788c2ecf20Sopenharmony_ci clrb BINDEC_FLG(%a6) |clr norm/denorm flag 1798c2ecf20Sopenharmony_ci movew STAG(%a6),%d0 |get stag 1808c2ecf20Sopenharmony_ci andiw #0xe000,%d0 |isolate stag bits 1818c2ecf20Sopenharmony_ci beq A2_str |if zero, input is norm 1828c2ecf20Sopenharmony_ci| 1838c2ecf20Sopenharmony_ci| Normalize the denorm 1848c2ecf20Sopenharmony_ci| 1858c2ecf20Sopenharmony_ciun_de_norm: 1868c2ecf20Sopenharmony_ci movew (%a0),%d0 1878c2ecf20Sopenharmony_ci andiw #0x7fff,%d0 |strip sign of normalized exp 1888c2ecf20Sopenharmony_ci movel 4(%a0),%d1 1898c2ecf20Sopenharmony_ci movel 8(%a0),%d2 1908c2ecf20Sopenharmony_cinorm_loop: 1918c2ecf20Sopenharmony_ci subw #1,%d0 1928c2ecf20Sopenharmony_ci lsll #1,%d2 1938c2ecf20Sopenharmony_ci roxll #1,%d1 1948c2ecf20Sopenharmony_ci tstl %d1 1958c2ecf20Sopenharmony_ci bges norm_loop 1968c2ecf20Sopenharmony_ci| 1978c2ecf20Sopenharmony_ci| Test if the normalized input is denormalized 1988c2ecf20Sopenharmony_ci| 1998c2ecf20Sopenharmony_ci tstw %d0 2008c2ecf20Sopenharmony_ci bgts pos_exp |if greater than zero, it is a norm 2018c2ecf20Sopenharmony_ci st BINDEC_FLG(%a6) |set flag for denorm 2028c2ecf20Sopenharmony_cipos_exp: 2038c2ecf20Sopenharmony_ci andiw #0x7fff,%d0 |strip sign of normalized exp 2048c2ecf20Sopenharmony_ci movew %d0,(%a0) 2058c2ecf20Sopenharmony_ci movel %d1,4(%a0) 2068c2ecf20Sopenharmony_ci movel %d2,8(%a0) 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci| A2. Set X = abs(input). 2098c2ecf20Sopenharmony_ci| 2108c2ecf20Sopenharmony_ciA2_str: 2118c2ecf20Sopenharmony_ci movel (%a0),FP_SCR2(%a6) | move input to work space 2128c2ecf20Sopenharmony_ci movel 4(%a0),FP_SCR2+4(%a6) | move input to work space 2138c2ecf20Sopenharmony_ci movel 8(%a0),FP_SCR2+8(%a6) | move input to work space 2148c2ecf20Sopenharmony_ci andil #0x7fffffff,FP_SCR2(%a6) |create abs(X) 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci| A3. Compute ILOG. 2178c2ecf20Sopenharmony_ci| ILOG is the log base 10 of the input value. It is approx- 2188c2ecf20Sopenharmony_ci| imated by adding e + 0.f when the original value is viewed 2198c2ecf20Sopenharmony_ci| as 2^^e * 1.f in extended precision. This value is stored 2208c2ecf20Sopenharmony_ci| in d6. 2218c2ecf20Sopenharmony_ci| 2228c2ecf20Sopenharmony_ci| Register usage: 2238c2ecf20Sopenharmony_ci| Input/Output 2248c2ecf20Sopenharmony_ci| d0: k-factor/exponent 2258c2ecf20Sopenharmony_ci| d2: x/x 2268c2ecf20Sopenharmony_ci| d3: x/x 2278c2ecf20Sopenharmony_ci| d4: x/x 2288c2ecf20Sopenharmony_ci| d5: x/x 2298c2ecf20Sopenharmony_ci| d6: x/ILOG 2308c2ecf20Sopenharmony_ci| d7: k-factor/Unchanged 2318c2ecf20Sopenharmony_ci| a0: ptr for original operand/final result 2328c2ecf20Sopenharmony_ci| a1: x/x 2338c2ecf20Sopenharmony_ci| a2: x/x 2348c2ecf20Sopenharmony_ci| fp0: x/float(ILOG) 2358c2ecf20Sopenharmony_ci| fp1: x/x 2368c2ecf20Sopenharmony_ci| fp2: x/x 2378c2ecf20Sopenharmony_ci| F_SCR1:x/x 2388c2ecf20Sopenharmony_ci| F_SCR2:Abs(X)/Abs(X) with $3fff exponent 2398c2ecf20Sopenharmony_ci| L_SCR1:x/x 2408c2ecf20Sopenharmony_ci| L_SCR2:first word of X packed/Unchanged 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci tstb BINDEC_FLG(%a6) |check for denorm 2438c2ecf20Sopenharmony_ci beqs A3_cont |if clr, continue with norm 2448c2ecf20Sopenharmony_ci movel #-4933,%d6 |force ILOG = -4933 2458c2ecf20Sopenharmony_ci bras A4_str 2468c2ecf20Sopenharmony_ciA3_cont: 2478c2ecf20Sopenharmony_ci movew FP_SCR2(%a6),%d0 |move exp to d0 2488c2ecf20Sopenharmony_ci movew #0x3fff,FP_SCR2(%a6) |replace exponent with 0x3fff 2498c2ecf20Sopenharmony_ci fmovex FP_SCR2(%a6),%fp0 |now fp0 has 1.f 2508c2ecf20Sopenharmony_ci subw #0x3fff,%d0 |strip off bias 2518c2ecf20Sopenharmony_ci faddw %d0,%fp0 |add in exp 2528c2ecf20Sopenharmony_ci fsubs FONE,%fp0 |subtract off 1.0 2538c2ecf20Sopenharmony_ci fbge pos_res |if pos, branch 2548c2ecf20Sopenharmony_ci fmulx LOG2UP1,%fp0 |if neg, mul by LOG2UP1 2558c2ecf20Sopenharmony_ci fmovel %fp0,%d6 |put ILOG in d6 as a lword 2568c2ecf20Sopenharmony_ci bras A4_str |go move out ILOG 2578c2ecf20Sopenharmony_cipos_res: 2588c2ecf20Sopenharmony_ci fmulx LOG2,%fp0 |if pos, mul by LOG2 2598c2ecf20Sopenharmony_ci fmovel %fp0,%d6 |put ILOG in d6 as a lword 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci| A4. Clr INEX bit. 2638c2ecf20Sopenharmony_ci| The operation in A3 above may have set INEX2. 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ciA4_str: 2668c2ecf20Sopenharmony_ci fmovel #0,%FPSR |zero all of fpsr - nothing needed 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci| A5. Set ICTR = 0; 2708c2ecf20Sopenharmony_ci| ICTR is a flag used in A13. It must be set before the 2718c2ecf20Sopenharmony_ci| loop entry A6. The lower word of d5 is used for ICTR. 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci clrw %d5 |clear ICTR 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci| A6. Calculate LEN. 2778c2ecf20Sopenharmony_ci| LEN is the number of digits to be displayed. The k-factor 2788c2ecf20Sopenharmony_ci| can dictate either the total number of digits, if it is 2798c2ecf20Sopenharmony_ci| a positive number, or the number of digits after the 2808c2ecf20Sopenharmony_ci| original decimal point which are to be included as 2818c2ecf20Sopenharmony_ci| significant. See the 68882 manual for examples. 2828c2ecf20Sopenharmony_ci| If LEN is computed to be greater than 17, set OPERR in 2838c2ecf20Sopenharmony_ci| USER_FPSR. LEN is stored in d4. 2848c2ecf20Sopenharmony_ci| 2858c2ecf20Sopenharmony_ci| Register usage: 2868c2ecf20Sopenharmony_ci| Input/Output 2878c2ecf20Sopenharmony_ci| d0: exponent/Unchanged 2888c2ecf20Sopenharmony_ci| d2: x/x/scratch 2898c2ecf20Sopenharmony_ci| d3: x/x 2908c2ecf20Sopenharmony_ci| d4: exc picture/LEN 2918c2ecf20Sopenharmony_ci| d5: ICTR/Unchanged 2928c2ecf20Sopenharmony_ci| d6: ILOG/Unchanged 2938c2ecf20Sopenharmony_ci| d7: k-factor/Unchanged 2948c2ecf20Sopenharmony_ci| a0: ptr for original operand/final result 2958c2ecf20Sopenharmony_ci| a1: x/x 2968c2ecf20Sopenharmony_ci| a2: x/x 2978c2ecf20Sopenharmony_ci| fp0: float(ILOG)/Unchanged 2988c2ecf20Sopenharmony_ci| fp1: x/x 2998c2ecf20Sopenharmony_ci| fp2: x/x 3008c2ecf20Sopenharmony_ci| F_SCR1:x/x 3018c2ecf20Sopenharmony_ci| F_SCR2:Abs(X) with $3fff exponent/Unchanged 3028c2ecf20Sopenharmony_ci| L_SCR1:x/x 3038c2ecf20Sopenharmony_ci| L_SCR2:first word of X packed/Unchanged 3048c2ecf20Sopenharmony_ci 3058c2ecf20Sopenharmony_ciA6_str: 3068c2ecf20Sopenharmony_ci tstl %d7 |branch on sign of k 3078c2ecf20Sopenharmony_ci bles k_neg |if k <= 0, LEN = ILOG + 1 - k 3088c2ecf20Sopenharmony_ci movel %d7,%d4 |if k > 0, LEN = k 3098c2ecf20Sopenharmony_ci bras len_ck |skip to LEN check 3108c2ecf20Sopenharmony_cik_neg: 3118c2ecf20Sopenharmony_ci movel %d6,%d4 |first load ILOG to d4 3128c2ecf20Sopenharmony_ci subl %d7,%d4 |subtract off k 3138c2ecf20Sopenharmony_ci addql #1,%d4 |add in the 1 3148c2ecf20Sopenharmony_cilen_ck: 3158c2ecf20Sopenharmony_ci tstl %d4 |LEN check: branch on sign of LEN 3168c2ecf20Sopenharmony_ci bles LEN_ng |if neg, set LEN = 1 3178c2ecf20Sopenharmony_ci cmpl #17,%d4 |test if LEN > 17 3188c2ecf20Sopenharmony_ci bles A7_str |if not, forget it 3198c2ecf20Sopenharmony_ci movel #17,%d4 |set max LEN = 17 3208c2ecf20Sopenharmony_ci tstl %d7 |if negative, never set OPERR 3218c2ecf20Sopenharmony_ci bles A7_str |if positive, continue 3228c2ecf20Sopenharmony_ci orl #opaop_mask,USER_FPSR(%a6) |set OPERR & AIOP in USER_FPSR 3238c2ecf20Sopenharmony_ci bras A7_str |finished here 3248c2ecf20Sopenharmony_ciLEN_ng: 3258c2ecf20Sopenharmony_ci moveql #1,%d4 |min LEN is 1 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci| A7. Calculate SCALE. 3298c2ecf20Sopenharmony_ci| SCALE is equal to 10^ISCALE, where ISCALE is the number 3308c2ecf20Sopenharmony_ci| of decimal places needed to insure LEN integer digits 3318c2ecf20Sopenharmony_ci| in the output before conversion to bcd. LAMBDA is the sign 3328c2ecf20Sopenharmony_ci| of ISCALE, used in A9. Fp1 contains 10^^(abs(ISCALE)) using 3338c2ecf20Sopenharmony_ci| the rounding mode as given in the following table (see 3348c2ecf20Sopenharmony_ci| Coonen, p. 7.23 as ref.; however, the SCALE variable is 3358c2ecf20Sopenharmony_ci| of opposite sign in bindec.sa from Coonen). 3368c2ecf20Sopenharmony_ci| 3378c2ecf20Sopenharmony_ci| Initial USE 3388c2ecf20Sopenharmony_ci| FPCR[6:5] LAMBDA SIGN(X) FPCR[6:5] 3398c2ecf20Sopenharmony_ci| ---------------------------------------------- 3408c2ecf20Sopenharmony_ci| RN 00 0 0 00/0 RN 3418c2ecf20Sopenharmony_ci| RN 00 0 1 00/0 RN 3428c2ecf20Sopenharmony_ci| RN 00 1 0 00/0 RN 3438c2ecf20Sopenharmony_ci| RN 00 1 1 00/0 RN 3448c2ecf20Sopenharmony_ci| RZ 01 0 0 11/3 RP 3458c2ecf20Sopenharmony_ci| RZ 01 0 1 11/3 RP 3468c2ecf20Sopenharmony_ci| RZ 01 1 0 10/2 RM 3478c2ecf20Sopenharmony_ci| RZ 01 1 1 10/2 RM 3488c2ecf20Sopenharmony_ci| RM 10 0 0 11/3 RP 3498c2ecf20Sopenharmony_ci| RM 10 0 1 10/2 RM 3508c2ecf20Sopenharmony_ci| RM 10 1 0 10/2 RM 3518c2ecf20Sopenharmony_ci| RM 10 1 1 11/3 RP 3528c2ecf20Sopenharmony_ci| RP 11 0 0 10/2 RM 3538c2ecf20Sopenharmony_ci| RP 11 0 1 11/3 RP 3548c2ecf20Sopenharmony_ci| RP 11 1 0 11/3 RP 3558c2ecf20Sopenharmony_ci| RP 11 1 1 10/2 RM 3568c2ecf20Sopenharmony_ci| 3578c2ecf20Sopenharmony_ci| Register usage: 3588c2ecf20Sopenharmony_ci| Input/Output 3598c2ecf20Sopenharmony_ci| d0: exponent/scratch - final is 0 3608c2ecf20Sopenharmony_ci| d2: x/0 or 24 for A9 3618c2ecf20Sopenharmony_ci| d3: x/scratch - offset ptr into PTENRM array 3628c2ecf20Sopenharmony_ci| d4: LEN/Unchanged 3638c2ecf20Sopenharmony_ci| d5: 0/ICTR:LAMBDA 3648c2ecf20Sopenharmony_ci| d6: ILOG/ILOG or k if ((k<=0)&(ILOG<k)) 3658c2ecf20Sopenharmony_ci| d7: k-factor/Unchanged 3668c2ecf20Sopenharmony_ci| a0: ptr for original operand/final result 3678c2ecf20Sopenharmony_ci| a1: x/ptr to PTENRM array 3688c2ecf20Sopenharmony_ci| a2: x/x 3698c2ecf20Sopenharmony_ci| fp0: float(ILOG)/Unchanged 3708c2ecf20Sopenharmony_ci| fp1: x/10^ISCALE 3718c2ecf20Sopenharmony_ci| fp2: x/x 3728c2ecf20Sopenharmony_ci| F_SCR1:x/x 3738c2ecf20Sopenharmony_ci| F_SCR2:Abs(X) with $3fff exponent/Unchanged 3748c2ecf20Sopenharmony_ci| L_SCR1:x/x 3758c2ecf20Sopenharmony_ci| L_SCR2:first word of X packed/Unchanged 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_ciA7_str: 3788c2ecf20Sopenharmony_ci tstl %d7 |test sign of k 3798c2ecf20Sopenharmony_ci bgts k_pos |if pos and > 0, skip this 3808c2ecf20Sopenharmony_ci cmpl %d6,%d7 |test k - ILOG 3818c2ecf20Sopenharmony_ci blts k_pos |if ILOG >= k, skip this 3828c2ecf20Sopenharmony_ci movel %d7,%d6 |if ((k<0) & (ILOG < k)) ILOG = k 3838c2ecf20Sopenharmony_cik_pos: 3848c2ecf20Sopenharmony_ci movel %d6,%d0 |calc ILOG + 1 - LEN in d0 3858c2ecf20Sopenharmony_ci addql #1,%d0 |add the 1 3868c2ecf20Sopenharmony_ci subl %d4,%d0 |sub off LEN 3878c2ecf20Sopenharmony_ci swap %d5 |use upper word of d5 for LAMBDA 3888c2ecf20Sopenharmony_ci clrw %d5 |set it zero initially 3898c2ecf20Sopenharmony_ci clrw %d2 |set up d2 for very small case 3908c2ecf20Sopenharmony_ci tstl %d0 |test sign of ISCALE 3918c2ecf20Sopenharmony_ci bges iscale |if pos, skip next inst 3928c2ecf20Sopenharmony_ci addqw #1,%d5 |if neg, set LAMBDA true 3938c2ecf20Sopenharmony_ci cmpl #0xffffecd4,%d0 |test iscale <= -4908 3948c2ecf20Sopenharmony_ci bgts no_inf |if false, skip rest 3958c2ecf20Sopenharmony_ci addil #24,%d0 |add in 24 to iscale 3968c2ecf20Sopenharmony_ci movel #24,%d2 |put 24 in d2 for A9 3978c2ecf20Sopenharmony_cino_inf: 3988c2ecf20Sopenharmony_ci negl %d0 |and take abs of ISCALE 3998c2ecf20Sopenharmony_ciiscale: 4008c2ecf20Sopenharmony_ci fmoves FONE,%fp1 |init fp1 to 1 4018c2ecf20Sopenharmony_ci bfextu USER_FPCR(%a6){#26:#2},%d1 |get initial rmode bits 4028c2ecf20Sopenharmony_ci lslw #1,%d1 |put them in bits 2:1 4038c2ecf20Sopenharmony_ci addw %d5,%d1 |add in LAMBDA 4048c2ecf20Sopenharmony_ci lslw #1,%d1 |put them in bits 3:1 4058c2ecf20Sopenharmony_ci tstl L_SCR2(%a6) |test sign of original x 4068c2ecf20Sopenharmony_ci bges x_pos |if pos, don't set bit 0 4078c2ecf20Sopenharmony_ci addql #1,%d1 |if neg, set bit 0 4088c2ecf20Sopenharmony_cix_pos: 4098c2ecf20Sopenharmony_ci leal RBDTBL,%a2 |load rbdtbl base 4108c2ecf20Sopenharmony_ci moveb (%a2,%d1),%d3 |load d3 with new rmode 4118c2ecf20Sopenharmony_ci lsll #4,%d3 |put bits in proper position 4128c2ecf20Sopenharmony_ci fmovel %d3,%fpcr |load bits into fpu 4138c2ecf20Sopenharmony_ci lsrl #4,%d3 |put bits in proper position 4148c2ecf20Sopenharmony_ci tstb %d3 |decode new rmode for pten table 4158c2ecf20Sopenharmony_ci bnes not_rn |if zero, it is RN 4168c2ecf20Sopenharmony_ci leal PTENRN,%a1 |load a1 with RN table base 4178c2ecf20Sopenharmony_ci bras rmode |exit decode 4188c2ecf20Sopenharmony_cinot_rn: 4198c2ecf20Sopenharmony_ci lsrb #1,%d3 |get lsb in carry 4208c2ecf20Sopenharmony_ci bccs not_rp |if carry clear, it is RM 4218c2ecf20Sopenharmony_ci leal PTENRP,%a1 |load a1 with RP table base 4228c2ecf20Sopenharmony_ci bras rmode |exit decode 4238c2ecf20Sopenharmony_cinot_rp: 4248c2ecf20Sopenharmony_ci leal PTENRM,%a1 |load a1 with RM table base 4258c2ecf20Sopenharmony_cirmode: 4268c2ecf20Sopenharmony_ci clrl %d3 |clr table index 4278c2ecf20Sopenharmony_cie_loop: 4288c2ecf20Sopenharmony_ci lsrl #1,%d0 |shift next bit into carry 4298c2ecf20Sopenharmony_ci bccs e_next |if zero, skip the mul 4308c2ecf20Sopenharmony_ci fmulx (%a1,%d3),%fp1 |mul by 10**(d3_bit_no) 4318c2ecf20Sopenharmony_cie_next: 4328c2ecf20Sopenharmony_ci addl #12,%d3 |inc d3 to next pwrten table entry 4338c2ecf20Sopenharmony_ci tstl %d0 |test if ISCALE is zero 4348c2ecf20Sopenharmony_ci bnes e_loop |if not, loop 4358c2ecf20Sopenharmony_ci 4368c2ecf20Sopenharmony_ci 4378c2ecf20Sopenharmony_ci| A8. Clr INEX; Force RZ. 4388c2ecf20Sopenharmony_ci| The operation in A3 above may have set INEX2. 4398c2ecf20Sopenharmony_ci| RZ mode is forced for the scaling operation to insure 4408c2ecf20Sopenharmony_ci| only one rounding error. The grs bits are collected in 4418c2ecf20Sopenharmony_ci| the INEX flag for use in A10. 4428c2ecf20Sopenharmony_ci| 4438c2ecf20Sopenharmony_ci| Register usage: 4448c2ecf20Sopenharmony_ci| Input/Output 4458c2ecf20Sopenharmony_ci 4468c2ecf20Sopenharmony_ci fmovel #0,%FPSR |clr INEX 4478c2ecf20Sopenharmony_ci fmovel #rz_mode,%FPCR |set RZ rounding mode 4488c2ecf20Sopenharmony_ci 4498c2ecf20Sopenharmony_ci 4508c2ecf20Sopenharmony_ci| A9. Scale X -> Y. 4518c2ecf20Sopenharmony_ci| The mantissa is scaled to the desired number of significant 4528c2ecf20Sopenharmony_ci| digits. The excess digits are collected in INEX2. If mul, 4538c2ecf20Sopenharmony_ci| Check d2 for excess 10 exponential value. If not zero, 4548c2ecf20Sopenharmony_ci| the iscale value would have caused the pwrten calculation 4558c2ecf20Sopenharmony_ci| to overflow. Only a negative iscale can cause this, so 4568c2ecf20Sopenharmony_ci| multiply by 10^(d2), which is now only allowed to be 24, 4578c2ecf20Sopenharmony_ci| with a multiply by 10^8 and 10^16, which is exact since 4588c2ecf20Sopenharmony_ci| 10^24 is exact. If the input was denormalized, we must 4598c2ecf20Sopenharmony_ci| create a busy stack frame with the mul command and the 4608c2ecf20Sopenharmony_ci| two operands, and allow the fpu to complete the multiply. 4618c2ecf20Sopenharmony_ci| 4628c2ecf20Sopenharmony_ci| Register usage: 4638c2ecf20Sopenharmony_ci| Input/Output 4648c2ecf20Sopenharmony_ci| d0: FPCR with RZ mode/Unchanged 4658c2ecf20Sopenharmony_ci| d2: 0 or 24/unchanged 4668c2ecf20Sopenharmony_ci| d3: x/x 4678c2ecf20Sopenharmony_ci| d4: LEN/Unchanged 4688c2ecf20Sopenharmony_ci| d5: ICTR:LAMBDA 4698c2ecf20Sopenharmony_ci| d6: ILOG/Unchanged 4708c2ecf20Sopenharmony_ci| d7: k-factor/Unchanged 4718c2ecf20Sopenharmony_ci| a0: ptr for original operand/final result 4728c2ecf20Sopenharmony_ci| a1: ptr to PTENRM array/Unchanged 4738c2ecf20Sopenharmony_ci| a2: x/x 4748c2ecf20Sopenharmony_ci| fp0: float(ILOG)/X adjusted for SCALE (Y) 4758c2ecf20Sopenharmony_ci| fp1: 10^ISCALE/Unchanged 4768c2ecf20Sopenharmony_ci| fp2: x/x 4778c2ecf20Sopenharmony_ci| F_SCR1:x/x 4788c2ecf20Sopenharmony_ci| F_SCR2:Abs(X) with $3fff exponent/Unchanged 4798c2ecf20Sopenharmony_ci| L_SCR1:x/x 4808c2ecf20Sopenharmony_ci| L_SCR2:first word of X packed/Unchanged 4818c2ecf20Sopenharmony_ci 4828c2ecf20Sopenharmony_ciA9_str: 4838c2ecf20Sopenharmony_ci fmovex (%a0),%fp0 |load X from memory 4848c2ecf20Sopenharmony_ci fabsx %fp0 |use abs(X) 4858c2ecf20Sopenharmony_ci tstw %d5 |LAMBDA is in lower word of d5 4868c2ecf20Sopenharmony_ci bne sc_mul |if neg (LAMBDA = 1), scale by mul 4878c2ecf20Sopenharmony_ci fdivx %fp1,%fp0 |calculate X / SCALE -> Y to fp0 4888c2ecf20Sopenharmony_ci bras A10_st |branch to A10 4898c2ecf20Sopenharmony_ci 4908c2ecf20Sopenharmony_cisc_mul: 4918c2ecf20Sopenharmony_ci tstb BINDEC_FLG(%a6) |check for denorm 4928c2ecf20Sopenharmony_ci beqs A9_norm |if norm, continue with mul 4938c2ecf20Sopenharmony_ci fmovemx %fp1-%fp1,-(%a7) |load ETEMP with 10^ISCALE 4948c2ecf20Sopenharmony_ci movel 8(%a0),-(%a7) |load FPTEMP with input arg 4958c2ecf20Sopenharmony_ci movel 4(%a0),-(%a7) 4968c2ecf20Sopenharmony_ci movel (%a0),-(%a7) 4978c2ecf20Sopenharmony_ci movel #18,%d3 |load count for busy stack 4988c2ecf20Sopenharmony_ciA9_loop: 4998c2ecf20Sopenharmony_ci clrl -(%a7) |clear lword on stack 5008c2ecf20Sopenharmony_ci dbf %d3,A9_loop 5018c2ecf20Sopenharmony_ci moveb VER_TMP(%a6),(%a7) |write current version number 5028c2ecf20Sopenharmony_ci moveb #BUSY_SIZE-4,1(%a7) |write current busy size 5038c2ecf20Sopenharmony_ci moveb #0x10,0x44(%a7) |set fcefpte[15] bit 5048c2ecf20Sopenharmony_ci movew #0x0023,0x40(%a7) |load cmdreg1b with mul command 5058c2ecf20Sopenharmony_ci moveb #0xfe,0x8(%a7) |load all 1s to cu savepc 5068c2ecf20Sopenharmony_ci frestore (%a7)+ |restore frame to fpu for completion 5078c2ecf20Sopenharmony_ci fmulx 36(%a1),%fp0 |multiply fp0 by 10^8 5088c2ecf20Sopenharmony_ci fmulx 48(%a1),%fp0 |multiply fp0 by 10^16 5098c2ecf20Sopenharmony_ci bras A10_st 5108c2ecf20Sopenharmony_ciA9_norm: 5118c2ecf20Sopenharmony_ci tstw %d2 |test for small exp case 5128c2ecf20Sopenharmony_ci beqs A9_con |if zero, continue as normal 5138c2ecf20Sopenharmony_ci fmulx 36(%a1),%fp0 |multiply fp0 by 10^8 5148c2ecf20Sopenharmony_ci fmulx 48(%a1),%fp0 |multiply fp0 by 10^16 5158c2ecf20Sopenharmony_ciA9_con: 5168c2ecf20Sopenharmony_ci fmulx %fp1,%fp0 |calculate X * SCALE -> Y to fp0 5178c2ecf20Sopenharmony_ci 5188c2ecf20Sopenharmony_ci 5198c2ecf20Sopenharmony_ci| A10. Or in INEX. 5208c2ecf20Sopenharmony_ci| If INEX is set, round error occurred. This is compensated 5218c2ecf20Sopenharmony_ci| for by 'or-ing' in the INEX2 flag to the lsb of Y. 5228c2ecf20Sopenharmony_ci| 5238c2ecf20Sopenharmony_ci| Register usage: 5248c2ecf20Sopenharmony_ci| Input/Output 5258c2ecf20Sopenharmony_ci| d0: FPCR with RZ mode/FPSR with INEX2 isolated 5268c2ecf20Sopenharmony_ci| d2: x/x 5278c2ecf20Sopenharmony_ci| d3: x/x 5288c2ecf20Sopenharmony_ci| d4: LEN/Unchanged 5298c2ecf20Sopenharmony_ci| d5: ICTR:LAMBDA 5308c2ecf20Sopenharmony_ci| d6: ILOG/Unchanged 5318c2ecf20Sopenharmony_ci| d7: k-factor/Unchanged 5328c2ecf20Sopenharmony_ci| a0: ptr for original operand/final result 5338c2ecf20Sopenharmony_ci| a1: ptr to PTENxx array/Unchanged 5348c2ecf20Sopenharmony_ci| a2: x/ptr to FP_SCR2(a6) 5358c2ecf20Sopenharmony_ci| fp0: Y/Y with lsb adjusted 5368c2ecf20Sopenharmony_ci| fp1: 10^ISCALE/Unchanged 5378c2ecf20Sopenharmony_ci| fp2: x/x 5388c2ecf20Sopenharmony_ci 5398c2ecf20Sopenharmony_ciA10_st: 5408c2ecf20Sopenharmony_ci fmovel %FPSR,%d0 |get FPSR 5418c2ecf20Sopenharmony_ci fmovex %fp0,FP_SCR2(%a6) |move Y to memory 5428c2ecf20Sopenharmony_ci leal FP_SCR2(%a6),%a2 |load a2 with ptr to FP_SCR2 5438c2ecf20Sopenharmony_ci btstl #9,%d0 |check if INEX2 set 5448c2ecf20Sopenharmony_ci beqs A11_st |if clear, skip rest 5458c2ecf20Sopenharmony_ci oril #1,8(%a2) |or in 1 to lsb of mantissa 5468c2ecf20Sopenharmony_ci fmovex FP_SCR2(%a6),%fp0 |write adjusted Y back to fpu 5478c2ecf20Sopenharmony_ci 5488c2ecf20Sopenharmony_ci 5498c2ecf20Sopenharmony_ci| A11. Restore original FPCR; set size ext. 5508c2ecf20Sopenharmony_ci| Perform FINT operation in the user's rounding mode. Keep 5518c2ecf20Sopenharmony_ci| the size to extended. The sintdo entry point in the sint 5528c2ecf20Sopenharmony_ci| routine expects the FPCR value to be in USER_FPCR for 5538c2ecf20Sopenharmony_ci| mode and precision. The original FPCR is saved in L_SCR1. 5548c2ecf20Sopenharmony_ci 5558c2ecf20Sopenharmony_ciA11_st: 5568c2ecf20Sopenharmony_ci movel USER_FPCR(%a6),L_SCR1(%a6) |save it for later 5578c2ecf20Sopenharmony_ci andil #0x00000030,USER_FPCR(%a6) |set size to ext, 5588c2ecf20Sopenharmony_ci| ;block exceptions 5598c2ecf20Sopenharmony_ci 5608c2ecf20Sopenharmony_ci 5618c2ecf20Sopenharmony_ci| A12. Calculate YINT = FINT(Y) according to user's rounding mode. 5628c2ecf20Sopenharmony_ci| The FPSP routine sintd0 is used. The output is in fp0. 5638c2ecf20Sopenharmony_ci| 5648c2ecf20Sopenharmony_ci| Register usage: 5658c2ecf20Sopenharmony_ci| Input/Output 5668c2ecf20Sopenharmony_ci| d0: FPSR with AINEX cleared/FPCR with size set to ext 5678c2ecf20Sopenharmony_ci| d2: x/x/scratch 5688c2ecf20Sopenharmony_ci| d3: x/x 5698c2ecf20Sopenharmony_ci| d4: LEN/Unchanged 5708c2ecf20Sopenharmony_ci| d5: ICTR:LAMBDA/Unchanged 5718c2ecf20Sopenharmony_ci| d6: ILOG/Unchanged 5728c2ecf20Sopenharmony_ci| d7: k-factor/Unchanged 5738c2ecf20Sopenharmony_ci| a0: ptr for original operand/src ptr for sintdo 5748c2ecf20Sopenharmony_ci| a1: ptr to PTENxx array/Unchanged 5758c2ecf20Sopenharmony_ci| a2: ptr to FP_SCR2(a6)/Unchanged 5768c2ecf20Sopenharmony_ci| a6: temp pointer to FP_SCR2(a6) - orig value saved and restored 5778c2ecf20Sopenharmony_ci| fp0: Y/YINT 5788c2ecf20Sopenharmony_ci| fp1: 10^ISCALE/Unchanged 5798c2ecf20Sopenharmony_ci| fp2: x/x 5808c2ecf20Sopenharmony_ci| F_SCR1:x/x 5818c2ecf20Sopenharmony_ci| F_SCR2:Y adjusted for inex/Y with original exponent 5828c2ecf20Sopenharmony_ci| L_SCR1:x/original USER_FPCR 5838c2ecf20Sopenharmony_ci| L_SCR2:first word of X packed/Unchanged 5848c2ecf20Sopenharmony_ci 5858c2ecf20Sopenharmony_ciA12_st: 5868c2ecf20Sopenharmony_ci moveml %d0-%d1/%a0-%a1,-(%a7) |save regs used by sintd0 5878c2ecf20Sopenharmony_ci movel L_SCR1(%a6),-(%a7) 5888c2ecf20Sopenharmony_ci movel L_SCR2(%a6),-(%a7) 5898c2ecf20Sopenharmony_ci leal FP_SCR2(%a6),%a0 |a0 is ptr to F_SCR2(a6) 5908c2ecf20Sopenharmony_ci fmovex %fp0,(%a0) |move Y to memory at FP_SCR2(a6) 5918c2ecf20Sopenharmony_ci tstl L_SCR2(%a6) |test sign of original operand 5928c2ecf20Sopenharmony_ci bges do_fint |if pos, use Y 5938c2ecf20Sopenharmony_ci orl #0x80000000,(%a0) |if neg, use -Y 5948c2ecf20Sopenharmony_cido_fint: 5958c2ecf20Sopenharmony_ci movel USER_FPSR(%a6),-(%a7) 5968c2ecf20Sopenharmony_ci bsr sintdo |sint routine returns int in fp0 5978c2ecf20Sopenharmony_ci moveb (%a7),USER_FPSR(%a6) 5988c2ecf20Sopenharmony_ci addl #4,%a7 5998c2ecf20Sopenharmony_ci movel (%a7)+,L_SCR2(%a6) 6008c2ecf20Sopenharmony_ci movel (%a7)+,L_SCR1(%a6) 6018c2ecf20Sopenharmony_ci moveml (%a7)+,%d0-%d1/%a0-%a1 |restore regs used by sint 6028c2ecf20Sopenharmony_ci movel L_SCR2(%a6),FP_SCR2(%a6) |restore original exponent 6038c2ecf20Sopenharmony_ci movel L_SCR1(%a6),USER_FPCR(%a6) |restore user's FPCR 6048c2ecf20Sopenharmony_ci 6058c2ecf20Sopenharmony_ci 6068c2ecf20Sopenharmony_ci| A13. Check for LEN digits. 6078c2ecf20Sopenharmony_ci| If the int operation results in more than LEN digits, 6088c2ecf20Sopenharmony_ci| or less than LEN -1 digits, adjust ILOG and repeat from 6098c2ecf20Sopenharmony_ci| A6. This test occurs only on the first pass. If the 6108c2ecf20Sopenharmony_ci| result is exactly 10^LEN, decrement ILOG and divide 6118c2ecf20Sopenharmony_ci| the mantissa by 10. The calculation of 10^LEN cannot 6128c2ecf20Sopenharmony_ci| be inexact, since all powers of ten up to 10^27 are exact 6138c2ecf20Sopenharmony_ci| in extended precision, so the use of a previous power-of-ten 6148c2ecf20Sopenharmony_ci| table will introduce no error. 6158c2ecf20Sopenharmony_ci| 6168c2ecf20Sopenharmony_ci| 6178c2ecf20Sopenharmony_ci| Register usage: 6188c2ecf20Sopenharmony_ci| Input/Output 6198c2ecf20Sopenharmony_ci| d0: FPCR with size set to ext/scratch final = 0 6208c2ecf20Sopenharmony_ci| d2: x/x 6218c2ecf20Sopenharmony_ci| d3: x/scratch final = x 6228c2ecf20Sopenharmony_ci| d4: LEN/LEN adjusted 6238c2ecf20Sopenharmony_ci| d5: ICTR:LAMBDA/LAMBDA:ICTR 6248c2ecf20Sopenharmony_ci| d6: ILOG/ILOG adjusted 6258c2ecf20Sopenharmony_ci| d7: k-factor/Unchanged 6268c2ecf20Sopenharmony_ci| a0: pointer into memory for packed bcd string formation 6278c2ecf20Sopenharmony_ci| a1: ptr to PTENxx array/Unchanged 6288c2ecf20Sopenharmony_ci| a2: ptr to FP_SCR2(a6)/Unchanged 6298c2ecf20Sopenharmony_ci| fp0: int portion of Y/abs(YINT) adjusted 6308c2ecf20Sopenharmony_ci| fp1: 10^ISCALE/Unchanged 6318c2ecf20Sopenharmony_ci| fp2: x/10^LEN 6328c2ecf20Sopenharmony_ci| F_SCR1:x/x 6338c2ecf20Sopenharmony_ci| F_SCR2:Y with original exponent/Unchanged 6348c2ecf20Sopenharmony_ci| L_SCR1:original USER_FPCR/Unchanged 6358c2ecf20Sopenharmony_ci| L_SCR2:first word of X packed/Unchanged 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_ciA13_st: 6388c2ecf20Sopenharmony_ci swap %d5 |put ICTR in lower word of d5 6398c2ecf20Sopenharmony_ci tstw %d5 |check if ICTR = 0 6408c2ecf20Sopenharmony_ci bne not_zr |if non-zero, go to second test 6418c2ecf20Sopenharmony_ci| 6428c2ecf20Sopenharmony_ci| Compute 10^(LEN-1) 6438c2ecf20Sopenharmony_ci| 6448c2ecf20Sopenharmony_ci fmoves FONE,%fp2 |init fp2 to 1.0 6458c2ecf20Sopenharmony_ci movel %d4,%d0 |put LEN in d0 6468c2ecf20Sopenharmony_ci subql #1,%d0 |d0 = LEN -1 6478c2ecf20Sopenharmony_ci clrl %d3 |clr table index 6488c2ecf20Sopenharmony_cil_loop: 6498c2ecf20Sopenharmony_ci lsrl #1,%d0 |shift next bit into carry 6508c2ecf20Sopenharmony_ci bccs l_next |if zero, skip the mul 6518c2ecf20Sopenharmony_ci fmulx (%a1,%d3),%fp2 |mul by 10**(d3_bit_no) 6528c2ecf20Sopenharmony_cil_next: 6538c2ecf20Sopenharmony_ci addl #12,%d3 |inc d3 to next pwrten table entry 6548c2ecf20Sopenharmony_ci tstl %d0 |test if LEN is zero 6558c2ecf20Sopenharmony_ci bnes l_loop |if not, loop 6568c2ecf20Sopenharmony_ci| 6578c2ecf20Sopenharmony_ci| 10^LEN-1 is computed for this test and A14. If the input was 6588c2ecf20Sopenharmony_ci| denormalized, check only the case in which YINT > 10^LEN. 6598c2ecf20Sopenharmony_ci| 6608c2ecf20Sopenharmony_ci tstb BINDEC_FLG(%a6) |check if input was norm 6618c2ecf20Sopenharmony_ci beqs A13_con |if norm, continue with checking 6628c2ecf20Sopenharmony_ci fabsx %fp0 |take abs of YINT 6638c2ecf20Sopenharmony_ci bra test_2 6648c2ecf20Sopenharmony_ci| 6658c2ecf20Sopenharmony_ci| Compare abs(YINT) to 10^(LEN-1) and 10^LEN 6668c2ecf20Sopenharmony_ci| 6678c2ecf20Sopenharmony_ciA13_con: 6688c2ecf20Sopenharmony_ci fabsx %fp0 |take abs of YINT 6698c2ecf20Sopenharmony_ci fcmpx %fp2,%fp0 |compare abs(YINT) with 10^(LEN-1) 6708c2ecf20Sopenharmony_ci fbge test_2 |if greater, do next test 6718c2ecf20Sopenharmony_ci subql #1,%d6 |subtract 1 from ILOG 6728c2ecf20Sopenharmony_ci movew #1,%d5 |set ICTR 6738c2ecf20Sopenharmony_ci fmovel #rm_mode,%FPCR |set rmode to RM 6748c2ecf20Sopenharmony_ci fmuls FTEN,%fp2 |compute 10^LEN 6758c2ecf20Sopenharmony_ci bra A6_str |return to A6 and recompute YINT 6768c2ecf20Sopenharmony_citest_2: 6778c2ecf20Sopenharmony_ci fmuls FTEN,%fp2 |compute 10^LEN 6788c2ecf20Sopenharmony_ci fcmpx %fp2,%fp0 |compare abs(YINT) with 10^LEN 6798c2ecf20Sopenharmony_ci fblt A14_st |if less, all is ok, go to A14 6808c2ecf20Sopenharmony_ci fbgt fix_ex |if greater, fix and redo 6818c2ecf20Sopenharmony_ci fdivs FTEN,%fp0 |if equal, divide by 10 6828c2ecf20Sopenharmony_ci addql #1,%d6 | and inc ILOG 6838c2ecf20Sopenharmony_ci bras A14_st | and continue elsewhere 6848c2ecf20Sopenharmony_cifix_ex: 6858c2ecf20Sopenharmony_ci addql #1,%d6 |increment ILOG by 1 6868c2ecf20Sopenharmony_ci movew #1,%d5 |set ICTR 6878c2ecf20Sopenharmony_ci fmovel #rm_mode,%FPCR |set rmode to RM 6888c2ecf20Sopenharmony_ci bra A6_str |return to A6 and recompute YINT 6898c2ecf20Sopenharmony_ci| 6908c2ecf20Sopenharmony_ci| Since ICTR <> 0, we have already been through one adjustment, 6918c2ecf20Sopenharmony_ci| and shouldn't have another; this is to check if abs(YINT) = 10^LEN 6928c2ecf20Sopenharmony_ci| 10^LEN is again computed using whatever table is in a1 since the 6938c2ecf20Sopenharmony_ci| value calculated cannot be inexact. 6948c2ecf20Sopenharmony_ci| 6958c2ecf20Sopenharmony_cinot_zr: 6968c2ecf20Sopenharmony_ci fmoves FONE,%fp2 |init fp2 to 1.0 6978c2ecf20Sopenharmony_ci movel %d4,%d0 |put LEN in d0 6988c2ecf20Sopenharmony_ci clrl %d3 |clr table index 6998c2ecf20Sopenharmony_ciz_loop: 7008c2ecf20Sopenharmony_ci lsrl #1,%d0 |shift next bit into carry 7018c2ecf20Sopenharmony_ci bccs z_next |if zero, skip the mul 7028c2ecf20Sopenharmony_ci fmulx (%a1,%d3),%fp2 |mul by 10**(d3_bit_no) 7038c2ecf20Sopenharmony_ciz_next: 7048c2ecf20Sopenharmony_ci addl #12,%d3 |inc d3 to next pwrten table entry 7058c2ecf20Sopenharmony_ci tstl %d0 |test if LEN is zero 7068c2ecf20Sopenharmony_ci bnes z_loop |if not, loop 7078c2ecf20Sopenharmony_ci fabsx %fp0 |get abs(YINT) 7088c2ecf20Sopenharmony_ci fcmpx %fp2,%fp0 |check if abs(YINT) = 10^LEN 7098c2ecf20Sopenharmony_ci fbne A14_st |if not, skip this 7108c2ecf20Sopenharmony_ci fdivs FTEN,%fp0 |divide abs(YINT) by 10 7118c2ecf20Sopenharmony_ci addql #1,%d6 |and inc ILOG by 1 7128c2ecf20Sopenharmony_ci addql #1,%d4 | and inc LEN 7138c2ecf20Sopenharmony_ci fmuls FTEN,%fp2 | if LEN++, the get 10^^LEN 7148c2ecf20Sopenharmony_ci 7158c2ecf20Sopenharmony_ci 7168c2ecf20Sopenharmony_ci| A14. Convert the mantissa to bcd. 7178c2ecf20Sopenharmony_ci| The binstr routine is used to convert the LEN digit 7188c2ecf20Sopenharmony_ci| mantissa to bcd in memory. The input to binstr is 7198c2ecf20Sopenharmony_ci| to be a fraction; i.e. (mantissa)/10^LEN and adjusted 7208c2ecf20Sopenharmony_ci| such that the decimal point is to the left of bit 63. 7218c2ecf20Sopenharmony_ci| The bcd digits are stored in the correct position in 7228c2ecf20Sopenharmony_ci| the final string area in memory. 7238c2ecf20Sopenharmony_ci| 7248c2ecf20Sopenharmony_ci| 7258c2ecf20Sopenharmony_ci| Register usage: 7268c2ecf20Sopenharmony_ci| Input/Output 7278c2ecf20Sopenharmony_ci| d0: x/LEN call to binstr - final is 0 7288c2ecf20Sopenharmony_ci| d1: x/0 7298c2ecf20Sopenharmony_ci| d2: x/ms 32-bits of mant of abs(YINT) 7308c2ecf20Sopenharmony_ci| d3: x/ls 32-bits of mant of abs(YINT) 7318c2ecf20Sopenharmony_ci| d4: LEN/Unchanged 7328c2ecf20Sopenharmony_ci| d5: ICTR:LAMBDA/LAMBDA:ICTR 7338c2ecf20Sopenharmony_ci| d6: ILOG 7348c2ecf20Sopenharmony_ci| d7: k-factor/Unchanged 7358c2ecf20Sopenharmony_ci| a0: pointer into memory for packed bcd string formation 7368c2ecf20Sopenharmony_ci| /ptr to first mantissa byte in result string 7378c2ecf20Sopenharmony_ci| a1: ptr to PTENxx array/Unchanged 7388c2ecf20Sopenharmony_ci| a2: ptr to FP_SCR2(a6)/Unchanged 7398c2ecf20Sopenharmony_ci| fp0: int portion of Y/abs(YINT) adjusted 7408c2ecf20Sopenharmony_ci| fp1: 10^ISCALE/Unchanged 7418c2ecf20Sopenharmony_ci| fp2: 10^LEN/Unchanged 7428c2ecf20Sopenharmony_ci| F_SCR1:x/Work area for final result 7438c2ecf20Sopenharmony_ci| F_SCR2:Y with original exponent/Unchanged 7448c2ecf20Sopenharmony_ci| L_SCR1:original USER_FPCR/Unchanged 7458c2ecf20Sopenharmony_ci| L_SCR2:first word of X packed/Unchanged 7468c2ecf20Sopenharmony_ci 7478c2ecf20Sopenharmony_ciA14_st: 7488c2ecf20Sopenharmony_ci fmovel #rz_mode,%FPCR |force rz for conversion 7498c2ecf20Sopenharmony_ci fdivx %fp2,%fp0 |divide abs(YINT) by 10^LEN 7508c2ecf20Sopenharmony_ci leal FP_SCR1(%a6),%a0 7518c2ecf20Sopenharmony_ci fmovex %fp0,(%a0) |move abs(YINT)/10^LEN to memory 7528c2ecf20Sopenharmony_ci movel 4(%a0),%d2 |move 2nd word of FP_RES to d2 7538c2ecf20Sopenharmony_ci movel 8(%a0),%d3 |move 3rd word of FP_RES to d3 7548c2ecf20Sopenharmony_ci clrl 4(%a0) |zero word 2 of FP_RES 7558c2ecf20Sopenharmony_ci clrl 8(%a0) |zero word 3 of FP_RES 7568c2ecf20Sopenharmony_ci movel (%a0),%d0 |move exponent to d0 7578c2ecf20Sopenharmony_ci swap %d0 |put exponent in lower word 7588c2ecf20Sopenharmony_ci beqs no_sft |if zero, don't shift 7598c2ecf20Sopenharmony_ci subil #0x3ffd,%d0 |sub bias less 2 to make fract 7608c2ecf20Sopenharmony_ci tstl %d0 |check if > 1 7618c2ecf20Sopenharmony_ci bgts no_sft |if so, don't shift 7628c2ecf20Sopenharmony_ci negl %d0 |make exp positive 7638c2ecf20Sopenharmony_cim_loop: 7648c2ecf20Sopenharmony_ci lsrl #1,%d2 |shift d2:d3 right, add 0s 7658c2ecf20Sopenharmony_ci roxrl #1,%d3 |the number of places 7668c2ecf20Sopenharmony_ci dbf %d0,m_loop |given in d0 7678c2ecf20Sopenharmony_cino_sft: 7688c2ecf20Sopenharmony_ci tstl %d2 |check for mantissa of zero 7698c2ecf20Sopenharmony_ci bnes no_zr |if not, go on 7708c2ecf20Sopenharmony_ci tstl %d3 |continue zero check 7718c2ecf20Sopenharmony_ci beqs zer_m |if zero, go directly to binstr 7728c2ecf20Sopenharmony_cino_zr: 7738c2ecf20Sopenharmony_ci clrl %d1 |put zero in d1 for addx 7748c2ecf20Sopenharmony_ci addil #0x00000080,%d3 |inc at bit 7 7758c2ecf20Sopenharmony_ci addxl %d1,%d2 |continue inc 7768c2ecf20Sopenharmony_ci andil #0xffffff80,%d3 |strip off lsb not used by 882 7778c2ecf20Sopenharmony_cizer_m: 7788c2ecf20Sopenharmony_ci movel %d4,%d0 |put LEN in d0 for binstr call 7798c2ecf20Sopenharmony_ci addql #3,%a0 |a0 points to M16 byte in result 7808c2ecf20Sopenharmony_ci bsr binstr |call binstr to convert mant 7818c2ecf20Sopenharmony_ci 7828c2ecf20Sopenharmony_ci 7838c2ecf20Sopenharmony_ci| A15. Convert the exponent to bcd. 7848c2ecf20Sopenharmony_ci| As in A14 above, the exp is converted to bcd and the 7858c2ecf20Sopenharmony_ci| digits are stored in the final string. 7868c2ecf20Sopenharmony_ci| 7878c2ecf20Sopenharmony_ci| Digits are stored in L_SCR1(a6) on return from BINDEC as: 7888c2ecf20Sopenharmony_ci| 7898c2ecf20Sopenharmony_ci| 32 16 15 0 7908c2ecf20Sopenharmony_ci| ----------------------------------------- 7918c2ecf20Sopenharmony_ci| | 0 | e3 | e2 | e1 | e4 | X | X | X | 7928c2ecf20Sopenharmony_ci| ----------------------------------------- 7938c2ecf20Sopenharmony_ci| 7948c2ecf20Sopenharmony_ci| And are moved into their proper places in FP_SCR1. If digit e4 7958c2ecf20Sopenharmony_ci| is non-zero, OPERR is signaled. In all cases, all 4 digits are 7968c2ecf20Sopenharmony_ci| written as specified in the 881/882 manual for packed decimal. 7978c2ecf20Sopenharmony_ci| 7988c2ecf20Sopenharmony_ci| Register usage: 7998c2ecf20Sopenharmony_ci| Input/Output 8008c2ecf20Sopenharmony_ci| d0: x/LEN call to binstr - final is 0 8018c2ecf20Sopenharmony_ci| d1: x/scratch (0);shift count for final exponent packing 8028c2ecf20Sopenharmony_ci| d2: x/ms 32-bits of exp fraction/scratch 8038c2ecf20Sopenharmony_ci| d3: x/ls 32-bits of exp fraction 8048c2ecf20Sopenharmony_ci| d4: LEN/Unchanged 8058c2ecf20Sopenharmony_ci| d5: ICTR:LAMBDA/LAMBDA:ICTR 8068c2ecf20Sopenharmony_ci| d6: ILOG 8078c2ecf20Sopenharmony_ci| d7: k-factor/Unchanged 8088c2ecf20Sopenharmony_ci| a0: ptr to result string/ptr to L_SCR1(a6) 8098c2ecf20Sopenharmony_ci| a1: ptr to PTENxx array/Unchanged 8108c2ecf20Sopenharmony_ci| a2: ptr to FP_SCR2(a6)/Unchanged 8118c2ecf20Sopenharmony_ci| fp0: abs(YINT) adjusted/float(ILOG) 8128c2ecf20Sopenharmony_ci| fp1: 10^ISCALE/Unchanged 8138c2ecf20Sopenharmony_ci| fp2: 10^LEN/Unchanged 8148c2ecf20Sopenharmony_ci| F_SCR1:Work area for final result/BCD result 8158c2ecf20Sopenharmony_ci| F_SCR2:Y with original exponent/ILOG/10^4 8168c2ecf20Sopenharmony_ci| L_SCR1:original USER_FPCR/Exponent digits on return from binstr 8178c2ecf20Sopenharmony_ci| L_SCR2:first word of X packed/Unchanged 8188c2ecf20Sopenharmony_ci 8198c2ecf20Sopenharmony_ciA15_st: 8208c2ecf20Sopenharmony_ci tstb BINDEC_FLG(%a6) |check for denorm 8218c2ecf20Sopenharmony_ci beqs not_denorm 8228c2ecf20Sopenharmony_ci ftstx %fp0 |test for zero 8238c2ecf20Sopenharmony_ci fbeq den_zero |if zero, use k-factor or 4933 8248c2ecf20Sopenharmony_ci fmovel %d6,%fp0 |float ILOG 8258c2ecf20Sopenharmony_ci fabsx %fp0 |get abs of ILOG 8268c2ecf20Sopenharmony_ci bras convrt 8278c2ecf20Sopenharmony_ciden_zero: 8288c2ecf20Sopenharmony_ci tstl %d7 |check sign of the k-factor 8298c2ecf20Sopenharmony_ci blts use_ilog |if negative, use ILOG 8308c2ecf20Sopenharmony_ci fmoves F4933,%fp0 |force exponent to 4933 8318c2ecf20Sopenharmony_ci bras convrt |do it 8328c2ecf20Sopenharmony_ciuse_ilog: 8338c2ecf20Sopenharmony_ci fmovel %d6,%fp0 |float ILOG 8348c2ecf20Sopenharmony_ci fabsx %fp0 |get abs of ILOG 8358c2ecf20Sopenharmony_ci bras convrt 8368c2ecf20Sopenharmony_cinot_denorm: 8378c2ecf20Sopenharmony_ci ftstx %fp0 |test for zero 8388c2ecf20Sopenharmony_ci fbne not_zero |if zero, force exponent 8398c2ecf20Sopenharmony_ci fmoves FONE,%fp0 |force exponent to 1 8408c2ecf20Sopenharmony_ci bras convrt |do it 8418c2ecf20Sopenharmony_cinot_zero: 8428c2ecf20Sopenharmony_ci fmovel %d6,%fp0 |float ILOG 8438c2ecf20Sopenharmony_ci fabsx %fp0 |get abs of ILOG 8448c2ecf20Sopenharmony_ciconvrt: 8458c2ecf20Sopenharmony_ci fdivx 24(%a1),%fp0 |compute ILOG/10^4 8468c2ecf20Sopenharmony_ci fmovex %fp0,FP_SCR2(%a6) |store fp0 in memory 8478c2ecf20Sopenharmony_ci movel 4(%a2),%d2 |move word 2 to d2 8488c2ecf20Sopenharmony_ci movel 8(%a2),%d3 |move word 3 to d3 8498c2ecf20Sopenharmony_ci movew (%a2),%d0 |move exp to d0 8508c2ecf20Sopenharmony_ci beqs x_loop_fin |if zero, skip the shift 8518c2ecf20Sopenharmony_ci subiw #0x3ffd,%d0 |subtract off bias 8528c2ecf20Sopenharmony_ci negw %d0 |make exp positive 8538c2ecf20Sopenharmony_cix_loop: 8548c2ecf20Sopenharmony_ci lsrl #1,%d2 |shift d2:d3 right 8558c2ecf20Sopenharmony_ci roxrl #1,%d3 |the number of places 8568c2ecf20Sopenharmony_ci dbf %d0,x_loop |given in d0 8578c2ecf20Sopenharmony_cix_loop_fin: 8588c2ecf20Sopenharmony_ci clrl %d1 |put zero in d1 for addx 8598c2ecf20Sopenharmony_ci addil #0x00000080,%d3 |inc at bit 6 8608c2ecf20Sopenharmony_ci addxl %d1,%d2 |continue inc 8618c2ecf20Sopenharmony_ci andil #0xffffff80,%d3 |strip off lsb not used by 882 8628c2ecf20Sopenharmony_ci movel #4,%d0 |put 4 in d0 for binstr call 8638c2ecf20Sopenharmony_ci leal L_SCR1(%a6),%a0 |a0 is ptr to L_SCR1 for exp digits 8648c2ecf20Sopenharmony_ci bsr binstr |call binstr to convert exp 8658c2ecf20Sopenharmony_ci movel L_SCR1(%a6),%d0 |load L_SCR1 lword to d0 8668c2ecf20Sopenharmony_ci movel #12,%d1 |use d1 for shift count 8678c2ecf20Sopenharmony_ci lsrl %d1,%d0 |shift d0 right by 12 8688c2ecf20Sopenharmony_ci bfins %d0,FP_SCR1(%a6){#4:#12} |put e3:e2:e1 in FP_SCR1 8698c2ecf20Sopenharmony_ci lsrl %d1,%d0 |shift d0 right by 12 8708c2ecf20Sopenharmony_ci bfins %d0,FP_SCR1(%a6){#16:#4} |put e4 in FP_SCR1 8718c2ecf20Sopenharmony_ci tstb %d0 |check if e4 is zero 8728c2ecf20Sopenharmony_ci beqs A16_st |if zero, skip rest 8738c2ecf20Sopenharmony_ci orl #opaop_mask,USER_FPSR(%a6) |set OPERR & AIOP in USER_FPSR 8748c2ecf20Sopenharmony_ci 8758c2ecf20Sopenharmony_ci 8768c2ecf20Sopenharmony_ci| A16. Write sign bits to final string. 8778c2ecf20Sopenharmony_ci| Sigma is bit 31 of initial value; RHO is bit 31 of d6 (ILOG). 8788c2ecf20Sopenharmony_ci| 8798c2ecf20Sopenharmony_ci| Register usage: 8808c2ecf20Sopenharmony_ci| Input/Output 8818c2ecf20Sopenharmony_ci| d0: x/scratch - final is x 8828c2ecf20Sopenharmony_ci| d2: x/x 8838c2ecf20Sopenharmony_ci| d3: x/x 8848c2ecf20Sopenharmony_ci| d4: LEN/Unchanged 8858c2ecf20Sopenharmony_ci| d5: ICTR:LAMBDA/LAMBDA:ICTR 8868c2ecf20Sopenharmony_ci| d6: ILOG/ILOG adjusted 8878c2ecf20Sopenharmony_ci| d7: k-factor/Unchanged 8888c2ecf20Sopenharmony_ci| a0: ptr to L_SCR1(a6)/Unchanged 8898c2ecf20Sopenharmony_ci| a1: ptr to PTENxx array/Unchanged 8908c2ecf20Sopenharmony_ci| a2: ptr to FP_SCR2(a6)/Unchanged 8918c2ecf20Sopenharmony_ci| fp0: float(ILOG)/Unchanged 8928c2ecf20Sopenharmony_ci| fp1: 10^ISCALE/Unchanged 8938c2ecf20Sopenharmony_ci| fp2: 10^LEN/Unchanged 8948c2ecf20Sopenharmony_ci| F_SCR1:BCD result with correct signs 8958c2ecf20Sopenharmony_ci| F_SCR2:ILOG/10^4 8968c2ecf20Sopenharmony_ci| L_SCR1:Exponent digits on return from binstr 8978c2ecf20Sopenharmony_ci| L_SCR2:first word of X packed/Unchanged 8988c2ecf20Sopenharmony_ci 8998c2ecf20Sopenharmony_ciA16_st: 9008c2ecf20Sopenharmony_ci clrl %d0 |clr d0 for collection of signs 9018c2ecf20Sopenharmony_ci andib #0x0f,FP_SCR1(%a6) |clear first nibble of FP_SCR1 9028c2ecf20Sopenharmony_ci tstl L_SCR2(%a6) |check sign of original mantissa 9038c2ecf20Sopenharmony_ci bges mant_p |if pos, don't set SM 9048c2ecf20Sopenharmony_ci moveql #2,%d0 |move 2 in to d0 for SM 9058c2ecf20Sopenharmony_cimant_p: 9068c2ecf20Sopenharmony_ci tstl %d6 |check sign of ILOG 9078c2ecf20Sopenharmony_ci bges wr_sgn |if pos, don't set SE 9088c2ecf20Sopenharmony_ci addql #1,%d0 |set bit 0 in d0 for SE 9098c2ecf20Sopenharmony_ciwr_sgn: 9108c2ecf20Sopenharmony_ci bfins %d0,FP_SCR1(%a6){#0:#2} |insert SM and SE into FP_SCR1 9118c2ecf20Sopenharmony_ci 9128c2ecf20Sopenharmony_ci| Clean up and restore all registers used. 9138c2ecf20Sopenharmony_ci 9148c2ecf20Sopenharmony_ci fmovel #0,%FPSR |clear possible inex2/ainex bits 9158c2ecf20Sopenharmony_ci fmovemx (%a7)+,%fp0-%fp2 9168c2ecf20Sopenharmony_ci moveml (%a7)+,%d2-%d7/%a2 9178c2ecf20Sopenharmony_ci rts 9188c2ecf20Sopenharmony_ci 9198c2ecf20Sopenharmony_ci |end 920