|
|
1.1 root 1:
2: #include "machine/fp.h"
3:
4:
5:
6: .text
7: .globl Xaddf
8: _addf:
9: Xaddf: .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,r2,r3.
14: # r0- 'pure' fraction, r2 - exponent, r3 - sign).
15: # The smaller operand will be fetched into r4,r6,r7.
16: #
17: clrl r1
18: andl3 $EXPMASK,4(fp),r0
19: andl3 $EXPMASK,12(fp),r1
20: cmpl r0,r1
21: jgtr first_greater
22:
23: movl 12(fp),r0 # bigger operand to r0
24:
25: movl 4(fp),r4 # smaller operand to r4
26: jmp expo
27:
28: first_greater:
29: movl 4(fp),r0 # bigger operand to r0
30:
31: movl 12(fp),r4 # smaller operand to r4
32:
33:
34: #
35: #compute exponents:
36: #
37: expo:
38: andl3 $EXPMASK,r0,r2 # r2 will hold the exponent of greater operand.
39: jeql is_res1 # check for reserved operand.
40: shrl $EXPSHIFT,r2,r2
41:
42:
43: andl3 $EXPMASK,r4,r6 # r6 will hold the exponent of smaller operand.
44: jeql is_res2 # check for reserved operand.
45: shrl $EXPSHIFT,r6,r6
46: #
47: #compare the exponents:
48: #
49: subl3 r6,r2,r8
50: jeql signs
51: cmpl r8,$MAX_EXP_DIF
52: jlss signs
53: ret # return the bigger number.
54:
55: #
56: #remember the signs:
57: #
58: signs:
59: clrl r3
60: bbc $31,r0,sign2 # if negative remember it.(R3=1)
61: incl r3
62: sign2:
63: clrl r7
64: bbc $31,r4,frac # if negative remember it.(R7=1)
65: incl r7
66: #
67: #compute 'pure' fraction:
68: #
69: frac:
70: # clear the non fraction parts.
71: andl2 $(0!(EXPMASK | SIGNBIT)),r0
72: # add the hidden bit.
73: orl2 $(0!CLEARHID),r0
74: # clear the non fraction parts.
75: andl2 $(0!(EXPMASK | SIGNBIT)),r4
76: # add the hidden bit.
77: orl2 $(0!CLEARHID),r4
78:
79: #
80: #shift the smaller operand:
81: #
82: shar r8,r4,r4
83: eql_exps:
84: cmpl r3,r7
85: jeql add
86: bbc $0,r3,negr4
87: #
88: #negate r0:
89: #
90: clrl r3
91: mnegl r0,r0
92:
93: #
94: #add the fractions:
95: #
96: add:
97: clrl r10
98: addl2 r4,r0
99: jgeq norm
100: incl r10
101: #
102: #negate the pair r0,r1:
103: #
104: mnegl r0,r0
105: norm: callf $4,sfnorm
106:
107: #
108: #add the sign bit
109: #
110: bbs $0,r10,negative
111: bbs $0,r3,negative # the bigger operand was negative.
112: ret
113: negative:
114: orl2 $SIGNBIT,r0
115: ret
116:
117:
118: #
119: #negate r4:
120: #
121: negr4:
122: mnegl r4,r4
123: jmp add
124:
125:
126: is_res1:
127: bbs $31,r0,res_op
128: movl r4,r0 # return the smaller operand.
129: ret
130:
131: is_res2:
132: bbs $31,r4,res_op
133: ret # we allready have the 'result' in r0,r1.
134:
135: res_op:
136: callf $4,sfpresop
137: ret
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.