|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
double z,z2,z3,a,b,diffa,diffb,sum;
int i;
z=0.75;
z2=z*z; // z2
z3=z2*z; // z3
a=z;
b=z2;
diffa=z2*z2; // z4
diffb=z2*z3; // z5
sum=1.0;
for (i=0;i<5;i++) // is 5 enough?
{
sum=sum-a-b;
a*=diffa;
b*=diffb;
diffa*=z3;
diffb*=z3;
sum=sum+a+b;
a*=diffa;
b*=diffb;
diffa*=z3;
diffb*=z3;
}
cout << “sum= “ << sum;
我翻译的mips程序:
.data
b: .word 0
n: .word 4
z. .double 0.75
c. .double 1
.text
l.d F1, z(R0)
mul.d F2,F1,F1
mul.d F3,F2,F1
mov.d F11,F1
mov.d F12,F2
mul.d F21,F2,F2
mul.d F22,F2,F3
l.d F31,c(R0)
ld R1,b(R0)
ld R2,n(R0)
loop:sub.d F31,F31,F11
sub.d F31,F31,F12
mul.d F11,F11,F21
mul.d F12,F12,F22
add.d F31,F31,F11
add.d F31,F31,F12
mul.d F11,F11,F21
mul.d F12,F12,F22
mul.d F21,F21,F3
mul.d F22,F22,F3
daddi R1,R1,1
bne R1,R2,loop
HALT
为什么用asm检查时老提示4,5,17行有错误? |
|