root/arch/i386/math-emu/round_Xsig.S

/* [previous][next][first][last][top][bottom][index][help] */
   1 /*---------------------------------------------------------------------------+
   2  |  round_Xsig.S                                                             |
   3  |                                                                           |
   4  | Copyright (C) 1992,1993,1994                                              |
   5  |                       W. Metzenthen, 22 Parker St, Ormond, Vic 3163,      |
   6  |                       Australia.  E-mail   billm@vaxc.cc.monash.edu.au    |
   7  |                                                                           |
   8  | Normalize and round a 12 byte quantity.                                   |
   9  | Call from C as:                                                           |
  10  |   int round_Xsig(Xsig *n)                                                 |
  11  |                                                                           |
  12  | Normalize a 12 byte quantity.                                             |
  13  | Call from C as:                                                           |
  14  |   int norm_Xsig(Xsig *n)                                                  |
  15  |                                                                           |
  16  | Each function returns the size of the shift (nr of bits).                 |
  17  |                                                                           |
  18  +---------------------------------------------------------------------------*/
  19         .file   "round_Xsig.S"
  20 
  21 #include "fpu_asm.h"
  22 
  23 
  24 .text
  25 
  26         .align 2,144
  27 .globl _round_Xsig
  28 
  29 _round_Xsig:
  30         pushl   %ebp
  31         movl    %esp,%ebp
  32         pushl   %ebx            /* Reserve some space */
  33         pushl   %ebx
  34         pushl   %esi
  35 
  36         movl    PARAM1,%esi
  37 
  38         movl    8(%esi),%edx
  39         movl    4(%esi),%ebx
  40         movl    (%esi),%eax
  41 
  42         movl    $0,-4(%ebp)
  43 
  44         orl     %edx,%edx       /* ms bits */
  45         js      L_round         /* Already normalized */
  46         jnz     L_shift_1       /* Shift left 1 - 31 bits */
  47 
  48         movl    %ebx,%edx
  49         movl    %eax,%ebx
  50         xorl    %eax,%eax
  51         movl    $-32,-4(%ebp)
  52 
  53 /* We need to shift left by 1 - 31 bits */
  54 L_shift_1:
  55         bsrl    %edx,%ecx       /* get the required shift in %ecx */
  56         subl    $31,%ecx
  57         negl    %ecx
  58         subl    %ecx,-4(%ebp)
  59         shld    %cl,%ebx,%edx
  60         shld    %cl,%eax,%ebx
  61         shl     %cl,%eax
  62 
  63 L_round:
  64         testl   $0x80000000,%eax
  65         jz      L_exit
  66 
  67         addl    $1,%ebx
  68         adcl    $0,%edx
  69         jnz     L_exit
  70 
  71         movl    $0x80000000,%edx
  72         incl    -4(%ebp)
  73 
  74 L_exit:
  75         movl    %edx,8(%esi)
  76         movl    %ebx,4(%esi)
  77         movl    %eax,(%esi)
  78 
  79         movl    -4(%ebp),%eax
  80 
  81         popl    %esi
  82         popl    %ebx
  83         leave
  84         ret
  85 
  86 
  87 
  88 
  89         .align 2,144
  90 .globl _norm_Xsig
  91 
  92 _norm_Xsig:
  93         pushl   %ebp
  94         movl    %esp,%ebp
  95         pushl   %ebx            /* Reserve some space */
  96         pushl   %ebx
  97         pushl   %esi
  98 
  99         movl    PARAM1,%esi
 100 
 101         movl    8(%esi),%edx
 102         movl    4(%esi),%ebx
 103         movl    (%esi),%eax
 104 
 105         movl    $0,-4(%ebp)
 106 
 107         orl     %edx,%edx       /* ms bits */
 108         js      L_n_exit                /* Already normalized */
 109         jnz     L_n_shift_1     /* Shift left 1 - 31 bits */
 110 
 111         movl    %ebx,%edx
 112         movl    %eax,%ebx
 113         xorl    %eax,%eax
 114         movl    $-32,-4(%ebp)
 115 
 116         orl     %edx,%edx       /* ms bits */
 117         js      L_n_exit        /* Normalized now */
 118         jnz     L_n_shift_1     /* Shift left 1 - 31 bits */
 119 
 120         movl    %ebx,%edx
 121         movl    %eax,%ebx
 122         xorl    %eax,%eax
 123         addl    $-32,-4(%ebp)
 124         jmp     L_n_exit        /* Might not be normalized,
 125                                    but shift no more. */
 126 
 127 /* We need to shift left by 1 - 31 bits */
 128 L_n_shift_1:
 129         bsrl    %edx,%ecx       /* get the required shift in %ecx */
 130         subl    $31,%ecx
 131         negl    %ecx
 132         subl    %ecx,-4(%ebp)
 133         shld    %cl,%ebx,%edx
 134         shld    %cl,%eax,%ebx
 135         shl     %cl,%eax
 136 
 137 L_n_exit:
 138         movl    %edx,8(%esi)
 139         movl    %ebx,4(%esi)
 140         movl    %eax,(%esi)
 141 
 142         movl    -4(%ebp),%eax
 143 
 144         popl    %esi
 145         popl    %ebx
 146         leave
 147         ret
 148 

/* [previous][next][first][last][top][bottom][index][help] */