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