1/* file: Ksqrtf.x 2*/ 3 .data 4 .comm _errno,4 5 .text 6LL0: .align 1 7 .globl _Ksqrtf 8 .data 9 .align 2 10L22: .long 0x40000000, 0x00000000 # .double .5 11 .text 12 .data 13 .align 2 14L23: .long 0x41000000, 0x00000000 # .double 2 15 .text 16 .data 17 .align 2 18L25: .long 0x41000000, 0x00000000 # .double 2 19 .text 20 .data 21 .align 2 22L26: .long 0x40000000, 0x00000000 # .double .5 23 .align 2 24L27: .long 0x40800000, 0x00000000 # .double 1 25 .text 26 .data 27 .align 2 28L30: .long 0x4F800000, 0x00000000 # .double 1073741824 29 .text 30 .data 31 .align 2 32L33: .long 0x4F800000, 0x00000000 # .double 1073741824 33 .text 34 .data 35 .align 2 36L39: .long 0x40000000, 0x00000000 # .double .5 37 .text 38 .set L14,0x0 39 .data 40 .text 41_Ksqrtf: .word L14 42 subl3 $76,fp,sp 43 tstl 4(fp) # if (arg <= 0.) { 44 jgtr L18 45 jgeq L19 # if (arg < 0.) 46 movl $33,_errno # errno = EDOM; 47L19: clrl r1 48 clrl r0 49 ret # return(0.);} 50L18: 51 pushl 20(fp) # hfs 52 subl3 $72,fp,-(sp) 53 pushl 8(fp) 54 pushl 4(fp) 55 callf $20,_Kfrexpf 56 clrl -60+4(fp) 57 movl r0,-60(fp) # x = frexp(arg,&exp); 58 jbr L20 59L2000001: 60 pushl 20(fp) # hfs 61 ldd L23 62 pushd 63 ldd -60(fp) 64 pushd 65 callf $24,_Kmuld # x * 2 66 ldd r0 67 std -60(fp) # x *= 2; 68 decl -72(fp) # exp--;} 69L20: cmpd2 -60(fp),L22 # while(x < 0.5){ 70 jlss L2000001 71 bitl $1,-72(fp) # if(exp & 1) { 72 jeql L24 73 pushl 20(fp) # hfs 74 ldd L25 75 pushd 76 ldd -60(fp) 77 pushd 78 callf $24,_Kmuld # x * 2 79 ldd r0 80 std -60(fp) # x *= 2; 81 decl -72(fp) # exp--;} 82L24: pushl 20(fp) # hfs 83 ldd -60(fp) 84 pushd 85 ldd L27 86 pushd 87 callf $24,_Kaddd # (1.0+x) 88 pushl 20(fp) # hfs 89 ldd r0 90 pushd 91 ldd L26 92 pushd 93 callf $24,_Kmuld 94 ldd r0 95 std -68(fp) # temp=0.5*(1.0+x); 96 jbr L28 97L2000003: 98 pushl 20(fp) # hfs 99 ldd L30 100 pushd 101 ldd -68(fp) 102 pushd 103 callf $24,_Kmuld # temp*(1L<<30) 104 ldd r0 105 std -68(fp) # temp *=(1L<<30); 106 subl2 $60,-72(fp) # exp -= 60;} 107L28: cmpl -72(fp),$60 # while(exp > 60){ 108 jleq L31 109 jbr L2000003 110L2000005: 111 pushl 20(fp) # hfs 112 ldd L33 113 pushd 114 ldd -68(fp) 115 pushd 116 callf $24,_Kdivd 117 ldd r0 118 std -68(fp) # temp /= (1L<<30); 119 addl2 $60,-72(fp) # exp +=60;} 120L31: cmpl -72(fp),$-60 # while(exp < -60) { 121 jlss L2000005 122 tstl -72(fp) # if(exp >=0) 123 jlss L34 124 divl3 $2,-72(fp),r0 125 shll r0,$1,r0 126 pushl 20(fp) # hfs 127 pushl $0 128 pushl r0 129 pushl $0 130 pushl $0 131 callf $24,_Kcvtld 132 pushl 20(fp) # hfs 133 ldd r0 134 pushd 135 ldd -68(fp) 136 pushd 137 callf $24,_Kmuld # temp * (1L <<(exp/2)) 138 jbr L2000006 # temp *= 1L << (exp/2)); 139L34: mnegl -72(fp),r0 # -exp 140 divl2 $2,r0 # -exp/2 141 shll r0,$1,r0 142 pushl 20(fp) # hfs 143 pushl $0 144 pushl r0 145 pushl $0 146 pushl $0 147 callf $24,_Kcvtld 148 pushl 20(fp) # hfs 149 ldd r0 150 pushd 151 ldd -68(fp) 152 pushd 153 callf $24,_Kdivd # temp / (1L <<(-exp/2)) 154L2000006: 155 ldd r0 156 std -68(fp) # temp (*/)= 1L << (exp/2)); 157 clrl -76(fp) 158L2000008: 159 pushl 20(fp) # hfs 160 ldd -68(fp) 161 pushd 162 ldd 4(fp) 163 pushd 164 callf $24,_Kdivd 165 pushl 20(fp) # hfs 166 ldd r0 167 pushd 168 ldd -68(fp) 169 pushd 170 callf $24,_Kaddd 171 pushl 20(fp) # hfs 172 ldd r0 173 pushd 174 ldd L39 175 pushd 176 callf $24,_Kmuld 177 ldd r0 178 std -68(fp) # temp=0.5*(temp+arg/temp); 179 aobleq $3,-76(fp),L2000008 180 ldd -68(fp) 181 cvdf 182 stf r0 183 ret 184