OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [i386/] [math-emu/] [reg_u_add.S] - Blame information for rev 1777

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1623 jcastillo
        .file   "reg_u_add.S"
2
/*---------------------------------------------------------------------------+
3
 |  reg_u_add.S                                                              |
4
 |                                                                           |
5
 | Add two valid (TW_Valid) FPU_REG numbers, of the same sign, and put the   |
6
 |   result in a destination FPU_REG.                                        |
7
 |                                                                           |
8
 | Copyright (C) 1992,1993,1995                                              |
9
 |                       W. Metzenthen, 22 Parker St, Ormond, Vic 3163,      |
10
 |                       Australia.  E-mail billm@jacobi.maths.monash.edu.au |
11
 |                                                                           |
12
 | Call from C as:                                                           |
13
 |   void reg_u_add(FPU_REG *arg1, FPU_REG *arg2, FPU_REG *answ,             |
14
 |                                                int control_w)             |
15
 |                                                                           |
16
 +---------------------------------------------------------------------------*/
17
 
18
/*
19
 |    Kernel addition routine reg_u_add(reg *arg1, reg *arg2, reg *answ).
20
 |    Takes two valid reg f.p. numbers (TW_Valid), which are
21
 |    treated as unsigned numbers,
22
 |    and returns their sum as a TW_Valid or TW_S f.p. number.
23
 |    The returned number is normalized.
24
 |    Basic checks are performed if PARANOID is defined.
25
 */
26
 
27
#include "exception.h"
28
#include "fpu_emu.h"
29
#include "control_w.h"
30
 
31
.text
32
ENTRY(reg_u_add)
33
        pushl   %ebp
34
        movl    %esp,%ebp
35
        pushl   %esi
36
        pushl   %edi
37
        pushl   %ebx
38
 
39
        movl    PARAM1,%esi             /* source 1 */
40
        movl    PARAM2,%edi             /* source 2 */
41
 
42
#ifdef DENORM_OPERAND
43
        cmpl    EXP_UNDER,EXP(%esi)
44
        jg      xOp1_not_denorm
45
 
46
        call    SYMBOL_NAME(denormal_operand)
47
        orl     %eax,%eax
48
        jnz     fpu_Arith_exit
49
 
50
xOp1_not_denorm:
51
        cmpl    EXP_UNDER,EXP(%edi)
52
        jg      xOp2_not_denorm
53
 
54
        call    SYMBOL_NAME(denormal_operand)
55
        orl     %eax,%eax
56
        jnz     fpu_Arith_exit
57
 
58
xOp2_not_denorm:
59
#endif DENORM_OPERAND
60
 
61
        movl    EXP(%esi),%ecx
62
        subl    EXP(%edi),%ecx          /* exp1 - exp2 */
63
        jge     L_arg1_larger
64
 
65
        /* num1 is smaller */
66
        movl    SIGL(%esi),%ebx
67
        movl    SIGH(%esi),%eax
68
 
69
        movl    %edi,%esi
70
        negw    %cx
71
        jmp     L_accum_loaded
72
 
73
L_arg1_larger:
74
        /* num1 has larger or equal exponent */
75
        movl    SIGL(%edi),%ebx
76
        movl    SIGH(%edi),%eax
77
 
78
L_accum_loaded:
79
        movl    PARAM3,%edi             /* destination */
80
/*      movb    SIGN(%esi),%dl
81
        movb    %dl,SIGN(%edi) */       /* Copy the sign from the first arg */
82
 
83
 
84
        movl    EXP(%esi),%edx
85
        movl    %edx,EXP(%edi)          /* Copy exponent to destination */
86
 
87
        xorl    %edx,%edx               /* clear the extension */
88
 
89
#ifdef PARANOID
90
        testl   $0x80000000,%eax
91
        je      L_bugged
92
 
93
        testl   $0x80000000,SIGH(%esi)
94
        je      L_bugged
95
#endif PARANOID
96
 
97
/* The number to be shifted is in %eax:%ebx:%edx */
98
        cmpw    $32,%cx         /* shrd only works for 0..31 bits */
99
        jnc     L_more_than_31
100
 
101
/* less than 32 bits */
102
        shrd    %cl,%ebx,%edx
103
        shrd    %cl,%eax,%ebx
104
        shr     %cl,%eax
105
        jmp     L_shift_done
106
 
107
L_more_than_31:
108
        cmpw    $64,%cx
109
        jnc     L_more_than_63
110
 
111
        subb    $32,%cl
112
        jz      L_exactly_32
113
 
114
        shrd    %cl,%eax,%edx
115
        shr     %cl,%eax
116
        orl     %ebx,%ebx
117
        jz      L_more_31_no_low        /* none of the lowest bits is set */
118
 
119
        orl     $1,%edx                 /* record the fact in the extension */
120
 
121
L_more_31_no_low:
122
        movl    %eax,%ebx
123
        xorl    %eax,%eax
124
        jmp     L_shift_done
125
 
126
L_exactly_32:
127
        movl    %ebx,%edx
128
        movl    %eax,%ebx
129
        xorl    %eax,%eax
130
        jmp     L_shift_done
131
 
132
L_more_than_63:
133
        cmpw    $65,%cx
134
        jnc     L_more_than_64
135
 
136
        movl    %eax,%edx
137
        orl     %ebx,%ebx
138
        jz      L_more_63_no_low
139
 
140
        orl     $1,%edx
141
        jmp     L_more_63_no_low
142
 
143
L_more_than_64:
144
        movl    $1,%edx         /* The shifted nr always at least one '1' */
145
 
146
L_more_63_no_low:
147
        xorl    %ebx,%ebx
148
        xorl    %eax,%eax
149
 
150
L_shift_done:
151
        /* Now do the addition */
152
        addl    SIGL(%esi),%ebx
153
        adcl    SIGH(%esi),%eax
154
        jnc     L_round_the_result
155
 
156
        /* Overflow, adjust the result */
157
        rcrl    $1,%eax
158
        rcrl    $1,%ebx
159
        rcrl    $1,%edx
160
        jnc     L_no_bit_lost
161
 
162
        orl     $1,%edx
163
 
164
L_no_bit_lost:
165
        incl    EXP(%edi)
166
 
167
L_round_the_result:
168
        jmp     fpu_reg_round   /* Round the result */
169
 
170
 
171
 
172
#ifdef PARANOID
173
/* If we ever get here then we have problems! */
174
L_bugged:
175
        pushl   EX_INTERNAL|0x201
176
        call    EXCEPTION
177
        pop     %ebx
178
        jmp     L_exit
179
#endif PARANOID
180
 
181
 
182
L_exit:
183
        popl    %ebx
184
        popl    %edi
185
        popl    %esi
186
        leave
187
        ret

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.