Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*---------------------------------------------------------------------------+
0003  |  round_Xsig.S                                                             |
0004  |                                                                           |
0005  | Copyright (C) 1992,1993,1994,1995                                         |
0006  |                       W. Metzenthen, 22 Parker St, Ormond, Vic 3163,      |
0007  |                       Australia.  E-mail billm@jacobi.maths.monash.edu.au |
0008  |                                                                           |
0009  | Normalize and round a 12 byte quantity.                                   |
0010  | Call from C as:                                                           |
0011  |   int round_Xsig(Xsig *n)                                                 |
0012  |                                                                           |
0013  | Normalize a 12 byte quantity.                                             |
0014  | Call from C as:                                                           |
0015  |   int norm_Xsig(Xsig *n)                                                  |
0016  |                                                                           |
0017  | Each function returns the size of the shift (nr of bits).                 |
0018  |                                                                           |
0019  +---------------------------------------------------------------------------*/
0020     .file   "round_Xsig.S"
0021 
0022 #include "fpu_emu.h"
0023 
0024 
0025 .text
0026 SYM_FUNC_START(round_Xsig)
0027     pushl   %ebp
0028     movl    %esp,%ebp
0029     pushl   %ebx        /* Reserve some space */
0030     pushl   %ebx
0031     pushl   %esi
0032 
0033     movl    PARAM1,%esi
0034 
0035     movl    8(%esi),%edx
0036     movl    4(%esi),%ebx
0037     movl    (%esi),%eax
0038 
0039     movl    $0,-4(%ebp)
0040 
0041     orl %edx,%edx   /* ms bits */
0042     js  L_round     /* Already normalized */
0043     jnz L_shift_1   /* Shift left 1 - 31 bits */
0044 
0045     movl    %ebx,%edx
0046     movl    %eax,%ebx
0047     xorl    %eax,%eax
0048     movl    $-32,-4(%ebp)
0049 
0050 /* We need to shift left by 1 - 31 bits */
0051 L_shift_1:
0052     bsrl    %edx,%ecx   /* get the required shift in %ecx */
0053     subl    $31,%ecx
0054     negl    %ecx
0055     subl    %ecx,-4(%ebp)
0056     shld    %cl,%ebx,%edx
0057     shld    %cl,%eax,%ebx
0058     shl %cl,%eax
0059 
0060 L_round:
0061     testl   $0x80000000,%eax
0062     jz  L_exit
0063 
0064     addl    $1,%ebx
0065     adcl    $0,%edx
0066     jnz L_exit
0067 
0068     movl    $0x80000000,%edx
0069     incl    -4(%ebp)
0070 
0071 L_exit:
0072     movl    %edx,8(%esi)
0073     movl    %ebx,4(%esi)
0074     movl    %eax,(%esi)
0075 
0076     movl    -4(%ebp),%eax
0077 
0078     popl    %esi
0079     popl    %ebx
0080     leave
0081     RET
0082 SYM_FUNC_END(round_Xsig)
0083 
0084 
0085 
0086 SYM_FUNC_START(norm_Xsig)
0087     pushl   %ebp
0088     movl    %esp,%ebp
0089     pushl   %ebx        /* Reserve some space */
0090     pushl   %ebx
0091     pushl   %esi
0092 
0093     movl    PARAM1,%esi
0094 
0095     movl    8(%esi),%edx
0096     movl    4(%esi),%ebx
0097     movl    (%esi),%eax
0098 
0099     movl    $0,-4(%ebp)
0100 
0101     orl %edx,%edx   /* ms bits */
0102     js  L_n_exit        /* Already normalized */
0103     jnz L_n_shift_1 /* Shift left 1 - 31 bits */
0104 
0105     movl    %ebx,%edx
0106     movl    %eax,%ebx
0107     xorl    %eax,%eax
0108     movl    $-32,-4(%ebp)
0109 
0110     orl %edx,%edx   /* ms bits */
0111     js  L_n_exit    /* Normalized now */
0112     jnz L_n_shift_1 /* Shift left 1 - 31 bits */
0113 
0114     movl    %ebx,%edx
0115     movl    %eax,%ebx
0116     xorl    %eax,%eax
0117     addl    $-32,-4(%ebp)
0118     jmp L_n_exit    /* Might not be normalized,
0119                                but shift no more. */
0120 
0121 /* We need to shift left by 1 - 31 bits */
0122 L_n_shift_1:
0123     bsrl    %edx,%ecx   /* get the required shift in %ecx */
0124     subl    $31,%ecx
0125     negl    %ecx
0126     subl    %ecx,-4(%ebp)
0127     shld    %cl,%ebx,%edx
0128     shld    %cl,%eax,%ebx
0129     shl %cl,%eax
0130 
0131 L_n_exit:
0132     movl    %edx,8(%esi)
0133     movl    %ebx,4(%esi)
0134     movl    %eax,(%esi)
0135 
0136     movl    -4(%ebp),%eax
0137 
0138     popl    %esi
0139     popl    %ebx
0140     leave
0141     RET
0142 SYM_FUNC_END(norm_Xsig)