📄 argred.s
字号:
signoff1: subl2 $4,r3 ashq r2,(r3),r8 bgeq signoff2 incl r10signoff2: subl2 $4,r3 ashq r2,(r3),r7 bgeq signoff3 incl r9signoff3:# p.5## Multiply the contents of r0/r1 by the # slice of 2/pi in r11 - r8 .# emul r0,r8,$0,r4 emul r0,r9,r5,r5 emul r0,r10,r6,r6 emul r1,r8,$0,r7 emul r1,r9,r8,r8 emul r1,r10,r9,r9 emul r1,r11,r10,r10 addl2 r4,r8 adwc r5,r9 adwc r6,r10# p.6## If there are more than five leading zeros# after the first two quotient bits or if there# are more than five leading ones after the first# two quotient bits, generate more fraction bits.# Otherwise, branch to code to produce the result.# bicl3 $0xc1ffffff,r10,r4 beql more1 cmpl $0x3e000000,r4 bneq resultmore1:# p.7## generate another 32 result bits.# subl2 $4,r3 ashq r2,(r3),r5 bgeq signoff4 emul r1,r6,$0,r4 addl2 r1,r5 emul r0,r6,r5,r5 addl2 r0,r6 brb addbits1signoff4: emul r1,r6,$0,r4 emul r0,r6,r5,r5addbits1: addl2 r5,r7 adwc r6,r8 adwc $0,r9 adwc $0,r10# p.8## Check for massive cancellation.# bicl3 $0xc0000000,r10,r6# bneq more2 -S.McD Test was backwards beql more2 cmpl $0x3fffffff,r6 bneq resultmore2:# p.9## If massive cancellation has occurred,# generate another 24 result bits.# Testing has shown there will always be # enough bits after this point.# subl2 $4,r3 ashq r2,(r3),r5 bgeq signoff5 emul r0,r6,r4,r5 addl2 r0,r6 brb addbits2signoff5: emul r0,r6,r4,r5addbits2: addl2 r6,r7 adwc $0,r8 adwc $0,r9 adwc $0,r10# p.10## The following code produces the reduced# argument from the product bits contained# in r10 - r7 .#result:## Extract the octant number from r10 .## extzv $29,$3,r10,r0 ...used for pi/4 reduction -S.McD extzv $30,$2,r10,r0## Clear the octant bits in r10 .## bicl2 $0xe0000000,r10 ...used for pi/4 reduction -S.McD bicl2 $0xc0000000,r10## Zero the sign flag.# clrl r5# p.11## Check to see if the fraction is greater than# or equal to one-half. If it is, add one # to the octant number, set the sign flag# on, and replace the fraction with 1 minus# the fraction.## bitl $0x10000000,r10 ...used for pi/4 reduction -S.McD bitl $0x20000000,r10 beql small incl r0 incl r5# subl3 r10,$0x1fffffff,r10 ...used for pi/4 reduction -S.McD subl3 r10,$0x3fffffff,r10 mcoml r9,r9 mcoml r8,r8 mcoml r7,r7small:# p.12### Test whether the first 29 bits of the ...used for pi/4 reduction -S.McD# Test whether the first 30 bits of the # fraction are zero.# tstl r10 beql tiny## Find the position of the first one bit in r10 .# cvtld r10,r1 extzv $7,$7,r1,r1## Compute the size of the shift needed.# subl3 r1,$32,r6## Shift up the high order 64 bits of the# product.# ashq r6,r9,r10 ashq r6,r8,r9 brb mult# p.13## Test to see if the sign bit of r9 is on.#tiny: tstl r9 bgeq tinier## If it is, shift the product bits up 32 bits.# movl $32,r6 movq r8,r10 tstl r10 brb mult# p.14## Test whether r9 is zero. It is probably# impossible for both r10 and r9 to be# zero, but until proven to be so, the test# must be made.#tinier: beql zero## Find the position of the first one bit in r9 .# cvtld r9,r1 extzv $7,$7,r1,r1## Compute the size of the shift needed.# subl3 r1,$32,r1 addl3 $32,r1,r6## Shift up the high order 64 bits of the# product.# ashq r1,r8,r10 ashq r1,r7,r9 brb mult# p.15## The following code sets the reduced# argument to zero.#zero: clrl r1 clrl r2 clrl r3 brw return# p.16## At this point, r0 contains the octant number,# r6 indicates the number of bits the fraction# has been shifted, r5 indicates the sign of# the fraction, r11/r10 contain the high order# 64 bits of the fraction, and the condition# codes indicate where the sign bit of r10# is on. The following code multiplies the# fraction by pi/2 .#mult:## Save r11/r10 in r4/r1 . -S.McD movl r11,r4 movl r10,r1## If the sign bit of r10 is on, add 1 to r11 .# bgeq signoff6 incl r11signoff6:# p.17## Move pi/2 into r3/r2 .# movq $0xc90fdaa22168c235,r2## Multiply the fraction by the portion of pi/2# in r2 .# emul r2,r10,$0,r7 emul r2,r11,r8,r7## Multiply the fraction by the portion of pi/2 # in r3 . emul r3,r10,$0,r9 emul r3,r11,r10,r10## Add the product bits together.# addl2 r7,r9 adwc r8,r10 adwc $0,r11## Compensate for not sign extending r8 above.-S.McD# tstl r8 bgeq signoff6a decl r11signoff6a:## Compensate for r11/r10 being unsigned. -S.McD# addl2 r2,r10 adwc r3,r11## Compensate for r3/r2 being unsigned. -S.McD# addl2 r1,r10 adwc r4,r11# p.18## If the sign bit of r11 is zero, shift the# product bits up one bit and increment r6 .# blss signon incl r6 ashq $1,r10,r10 tstl r9 bgeq signoff7 incl r10signoff7:signon:# p.19## Shift the 56 most significant product# bits into r9/r8 . The sign extension# will be handled later.# ashq $-8,r10,r8## Convert the low order 8 bits of r10# into an F-format number.# cvtbf r10,r3## If the result of the conversion was# negative, add 1 to r9/r8 .# bgeq chop incl r8 adwc $0,r9## If r9 is now zero, branch to special# code to handle that possibility.# beql carryoutchop:# p.20## Convert the number in r9/r8 into# D-format number in r2/r1 .# rotl $16,r8,r2 rotl $16,r9,r1## Set the exponent field to the appropriate# value. Note that the extra bits created by# sign extension are now eliminated.# subw3 r6,$131,r6 insv r6,$7,$9,r1## Set the exponent field of the F-format# number in r3 to the appropriate value.# tstf r3 beql return# extzv $7,$8,r3,r4 -S.McD extzv $7,$7,r3,r4 addw2 r4,r6# subw2 $217,r6 -S.McD subw2 $64,r6 insv r6,$7,$8,r3 brb return# p.21## The following code generates the appropriate # result for the unlikely possibility that# rounding the number in r9/r8 resulted in # a carry out.#carryout: clrl r1 clrl r2 subw3 r6,$132,r6 insv r6,$7,$9,r1 tstf r3 beql return extzv $7,$8,r3,r4 addw2 r4,r6 subw2 $218,r6 insv r6,$7,$8,r3# p.22## The following code makes an needed# adjustments to the signs of the # results or to the octant number, and# then returns.#return:## Test if the fraction was greater than or # equal to 1/2 . If so, negate the reduced# argument.# blbc r5,signoff8 mnegf r1,r1 mnegf r3,r3signoff8:# p.23## If the original argument was negative,# negate the reduce argument and# adjust the octant number.# tstw (sp)+ bgeq signoff9 mnegf r1,r1 mnegf r3,r3# subb3 r0,$8,r0 ...used for pi/4 reduction -S.McD subb3 r0,$4,r0signoff9:## Clear all unneeded octant bits.## bicb2 $0xf8,r0 ...used for pi/4 reduction -S.McD bicb2 $0xfc,r0## Return.# rsb
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -