|
|
1.1 root 1:
2: #include <machine/fp.h>
3:
4:
5:
6: .text
7: .globl Xaddd
8: _addd:
9: Xaddd: .word 0x1ffc # we use many registers...
10:
11: #
12: # see which operand has a greater exponent
13: # The greater one will be fetched into r0,r1,r2,r3.
14: # r0,r1 - 'pure' fraction, r2 - exponent, r3 - sign).
15: # The smaller operand will be fetched into r4,r5,r6,r7.
16: #
17: andl3 $EXPMASK,4(fp),r0
18: andl3 $EXPMASK,12(fp),r1
19: cmpl r0,r1
20: jgtr first_greater
21:
22: movl 12(fp),r0 # bigger operand to r0,r1
23: movl 16(fp),r1
24:
25: movl 4(fp),r4 # smaller operand to r4,r5
26: movl 8(fp),r5
27: jmp expo
28:
29: first_greater:
30: movl 4(fp),r0 # bigger operand to r0,r1
31: movl 8(fp),r1
32:
33: movl 12(fp),r4 # smaller operand to r4,r5
34: movl 16(fp),r5
35:
36:
37: #
38: #compute exponents:
39: #
40: expo:
41: andl3 $EXPMASK,r0,r2 # r2 will hold the exponent.
42: jeql is_res1 # check for reserved operand.
43: shrl $EXPSHIFT,r2,r2
44:
45:
46: andl3 $EXPMASK,r4,r6 # r6 will hold the exponent.
47: jeql is_res2 # check for reserved operand.
48: shrl $EXPSHIFT,r6,r6
49: #
50: #compare the exponents:
51: #
52: subl3 r6,r2,r8
53: jeql signs
54: cmpl r8,$MAX_EXP_DIF
55: jlss signs
56: ret # return the bigger number.
57:
58: #
59: #remember the signs:
60: #
61: signs:
62: clrl r3
63: bbc $31,r0,sign2 # if negative remember it.
64: incl r3
65: sign2:
66: clrl r7
67: bbc $31,r4,frac # if negative remember it.
68: incl r7
69: #
70: #compute 'pure' fraction:
71: #
72: frac:
73: # clear the non fraction parts.
74: andl2 $(0!(EXPMASK | SIGNBIT)),r0
75: # add the hidden bit.
76: orl2 $(0!CLEARHID),r0
77: # clear the non fraction parts.
78: andl2 $(0!(EXPMASK | SIGNBIT)),r4
79: # add the hidden bit.
80: orl2 $(0!CLEARHID),r4
81:
82: #
83: #shift the smaller operand:
84: #
85: shrq r8,r4,r4
86: eql_exps:
87: cmpl r3,r7
88: jeql add
89: bbc $0,r3,negr4r5
90: #
91: #negate the pair r0,r1:
92: #
93: clrl r3
94: mcoml r1,r1
95: clrl r9 # r9 - carry flag.
96: incl r1
97: bcc comr0
98: incl r9 # remember the carry.
99: comr0: mcoml r0,r0
100: bbc $0,r9,add
101: incl r0
102:
103: #
104: #add the fractions:
105: #
106: add:
107: clrl r10 # to remember the sign of the result.
108: addl2 r5,r1
109: adwc r4,r0
110: jgeq norm # if positive go to normelize.
111: incl r10 # else remember it and negate the result.
112: #
113: #negate the pair r0,r1:
114: #
115: clrl r3
116: mcoml r1,r1
117: clrl r9 # r9 - carry flag.
118: incl r1
119: bcc comr00
120: incl r9 # remember the carry.
121: comr00: mcoml r0,r0
122: bbc $0,r9,norm
123: incl r0
124: norm: callf $4,fnorm
125:
126: #
127: #add the sign bit
128: #
129: bbs $0,r10,negative
130: bbs $0,r3,negative
131: ret
132: negative:
133: orl2 $SIGNBIT,r0
134: ret
135:
136:
137: #
138: #negate the pair r4,r5:
139: #
140: negr4r5:
141: clrl r7
142: mcoml r5,r5
143: clrl r9 # r9 - carry flag.
144: incl r5
145: bcc comr4
146: incl r9 # remember the carry.
147: comr4: mcoml r4,r4
148: bbc $0,r9,add
149: incl r4
150: jmp add
151:
152:
153: is_res1:
154: bbs $31,r0,res_op
155: movl r4,r0 # return the smaller operand.
156: movl r5,r1
157: ret
158:
159: is_res2:
160: bbs $31,r4,res_op
161: ret # we allready have the 'result' in r0,r1.
162:
163: res_op:
164: callf $4,fpresop
165: ret
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.