📄 fputest.c
字号:
return(0);}float_to_integer_sp() { int i; unsigned long result; clear_regs(0); for (i = 0; i < 200; i++) { result = float_int_s(val[i].floatsingle); if (result != i) { send_message(0, ERROR, "\nfstoi failed: int = %d, expected / observed = %x / %x\n", i, i, result); return(-1); } } return(0);}float_to_integer_dp() { int i; unsigned long res1, result; clear_regs(0); for (i = 0; i < 200; i++) { res1 = float_int_d(val[i].floatdouble); if (res1 != i) { send_message(0, ERROR, "\nfdtoi failed: int = %d, expected / observed = %x / %x\n", i, i, res1); return(-1); } } return(0);}single_doub(){ int i, j; unsigned long result; clear_regs(0); for (i = 0; i < 200; i++) { result = convert_sp_dp(val[i].floatsingle); if (result != val[i].floatdouble) { send_message(0, ERROR, "\nfstod failed: int = %d, expected / observed = %x / %x\n", i, val[i].floatdouble, result); return(-1); } } return(0);}double_sing(){ int i, j; unsigned long result; clear_regs(0); for (i = 0; i < 200; i++) { result = convert_dp_sp(val[i].floatdouble); if (result != val[i].floatsingle) { send_message(0, ERROR, "\nfdtos failed: int = %d, expected / observed = %x / %x\n", i, val[i].floatsingle, result); return(-1); } } return(0);}fmovs_ins(){ unsigned long result; clear_regs(0); if ((result = move_regs(0x3F800000)) != 0x3F800000) { send_message(0, ERROR, "\nfmovs failed : written %x to f0, read from f31 = %x\n", 0x3F800000, result); return(-1); } return(0);}get_negative_value_pn(){ int i; unsigned long result; clear_regs(0); for (i = 0; i < 17 ; i++) { result = negate_value(val[i].floatsingle); if (result != neg_val[i]) { send_message(0, ERROR, "\nfnegs failed(from pos to neg): int = %d, expected / observed = %x / %x\n", i, neg_val[i], result); return(-1); } } return(0);}get_negative_value_np(){ int i; unsigned long result; clear_regs(0); for (i = 0; i < 17; i++) { result = negate_value(neg_val[i]); if (result != val[i].floatsingle) { send_message(0, ERROR, "\nfnegs failed (from neg. to pos): int = %d, expected / observed = %x / %x\n", i, val[i].floatsingle, result); return(-1); } } return(0);}fabs_ins(){ int i, j; unsigned long result; clear_regs(0); for (i = 0; i < 17; i++) { result = absolute_value(neg_val[i]); if (result != val[i].floatsingle) { send_message(0, ERROR, "\nfabs failed: int = %d, expected / observed = %x / %x\n", i, val[i].floatsingle, result); return(-1); } } return(0);}addition_test_sp(){ int i; unsigned long result; clear_regs(0); for (i = 0; i < 200; i++) { result = add_sp(val[i].floatsingle, val[1].floatsingle); if (result != (val[i+1].floatsingle)) { send_message(0, ERROR, "\nfadds failed: int = %d, f0 = %x, f2 = %x, f0+f2 = f4 = %x\n", i+1, val[i].floatsingle, val[1].floatsingle, result); return(-1); } } return(0);}addition_test_dp(){ int i; unsigned long result; clear_regs(0); for (i = 0; i < 200; i++) { result = add_dp(val[i].floatdouble, val[1].floatdouble); if (result != (val[i+1].floatdouble)) { send_message(0, ERROR, "\nfaddd failed: int = %d, f0 = %x, f2 = %x, f0+f2 = f4 = %x\n", i+1, val[i].floatdouble, val[1].floatdouble, result); return(-1); } } return(0);}subtraction_test_sp(){ int i; unsigned long result; clear_regs(0); for (i = 1; i < 200; i++) { result = sub_sp(val[i].floatsingle, val[i-1].floatsingle); if (result != val[1].floatsingle) { send_message(0, ERROR, "\nfsubs failed:int = %d, f0 = %x, f2 = %x, f0-f2 = f4 = %x\n", i-1,val[i].floatsingle, val[i-1].floatsingle, result); return(-1); } } return(0);}subtraction_test_dp(){ int i; unsigned long result; clear_regs(0); for (i = 1; i < 200; i++) { result = sub_dp(val[i].floatdouble, val[i-1].floatdouble); if (result != val[1].floatdouble) { send_message(0, ERROR, "\bfsubd failed: int = %d, f0 = %x, f2 = %x, f0-f2 = f4 = %x\n", i-1,val[i].floatdouble, val[i-1].floatdouble, result); return(-1); } } return(0);} squareroot_test_sp(){ int i; unsigned long result, workvalue; if (fpu_is_weitek()) return(0); /* skip on Weitek fpu */ clear_regs(0); for (i = 1; i < 200; i++) { workvalue = val[i].floatsingle; result = square_sp( mult_sp(workvalue,workvalue) ); if (result != workvalue) { send_message(0, ERROR, "\nfsqrt failed: written / read = %x / %x\n", workvalue, result); return(1); } } return(0); /* test passed - no errors detected */}squareroot_test_dp(){ int i; unsigned long result, workvalue; if (fpu_is_weitek()) return(0); /* skip on Weitek fpu */ clear_regs(0); for (i = 1; i < 200; i++) { workvalue = val[i].floatdouble; result = square_dp( mult_dp(workvalue,workvalue) ); if (result != workvalue) { send_message(0, ERROR, "\nfsqrt failed: written / read = %x / %x\n", workvalue, result); return(1); } } return(0); /* test passed - no errors detected */}division_test_sp(){ int i; unsigned long result; clear_regs(0); for (i = 1; i < 200; i++) { result = div_sp(val[i].floatsingle, val[1].floatsingle); if (result != val[i].floatsingle) { send_message(0, ERROR, "\nfdivs failed: int = %d, f0 = %x, f2 = %x, f0 / f2 = f4 = %x\n", i, val[i].floatsingle, val[1].floatsingle, result); return(-1); } } return(0);}division_test_dp(){ int i; unsigned long result; clear_regs(0); for (i = 1; i < 200; i++) { result = div_dp(val[i].floatdouble, val[1].floatdouble); if (result != val[i].floatdouble) { send_message(0, ERROR, "\nfdivd failed: int = %d, f0 = %x, f2 = %x, f0 / f2 = f4 = %x\n", i, val[i].floatdouble, val[1].floatdouble, result); return(-1); } } return(0);}multiplication_test_sp(){ int i; unsigned long result; clear_regs(0); for (i = 0; i < 200; i++) { result = mult_sp(val[i].floatsingle, val[1].floatsingle); if (result != val[i].floatsingle) { send_message(0, ERROR, "\nfmuls failed: int = %d, f0 = %x, f2 = %x, f0 / f2 = f4 = %x\n", i, val[i].floatsingle, val[1].floatsingle, result); return(-1); } } return(0);}multiplication_test_dp(){ int i; unsigned long result; clear_regs(0); for (i = 0; i < 200; i++) { result = mult_dp(val[i].floatdouble, val[1].floatdouble); if (result != val[i].floatdouble) { send_message(0, ERROR, "\nfmuld failed: int = %d, f0 = %x, f2 = %x, f0 / f2 = f4 = %x\n", i, val[i].floatdouble, val[1].floatdouble, result); return(-1); } } return(0); } compare_sp(){ int i; unsigned long result; clear_regs(0); for (i = 0; i < 200; i++) { result = cmp_s(val[i].floatsingle, val[i].floatsingle); if ((result & 0xc00) != 0) { send_message(0, ERROR, "\nfcmps failed: f0 = %d, f2 = %d : expected / observed = 0 / %x\n", i,i,(result & 0xc00) >> 10); return(-1); } result = cmp_s(val[i].floatsingle, val[i+1].floatsingle); if ((result & 0xc00) != 0x400) { send_message(0, ERROR, "\nfcmps failed: f0 = %d, f2 = %d : expected / observed = 1 /%x\n", i,i+1, (result & 0xc00) >> 10); return(-1); } result = cmp_s(val[i+1].floatsingle, val[i].floatsingle); if ((result & 0xc00) != 0x800) { send_message(0, ERROR, "\nfcmps failed: f0 = %d, f2 = %d : expected / observed = 2 /%x\n", i+1, i,(result & 0xc00) >> 10); return(-1); } result = cmp_s(val[i].floatsingle,0x7f800400); if ((result & 0xc00) != 0xc00){ send_message(0, ERROR, "\nfcmps failed: f0 = %d, f2 = NaN : expected / observed = 3 /%x\n", i,(result & 0xc00) >> 10); return(-1); } } return(0);}compare_dp(){ int i; unsigned long result; clear_regs(0); for (i = 0; i < 200; i++) { result = cmp_d(val[i].floatdouble, val[i].floatdouble); if ((result & 0xc00) != 0) { send_message(0, ERROR, "\nfcmpd failed: f0 = %d, f2 = %d : expected / observed = 0 / %x\n", i,i,(result & 0xc00) >> 10); return(-1); } result = cmp_d(val[i].floatdouble, val[i+1].floatdouble); if ((result & 0xc00) != 0x400) { send_message(0, ERROR, "\nfcmpd failed: f0 = %d, f2 = %d : expected / observed = 1 /%x\n", i, i+1,(result & 0xc00) >> 10); return(-1); } result = cmp_d(val[i+1].floatdouble, val[i].floatdouble); if ((result & 0xc00) != 0x800) { send_message(0, ERROR, "\nfcmpd failed: f0 = %d, f2 = %d : expected / observed = 2 /%x\n", i+1, i,(result & 0xc00) >> 10); return(-1); } result = cmp_d(val[i].floatdouble, 0x7ff00080); if ((result & 0xc00) != 0xc00) { send_message(0, ERROR, "\nfcmpd failed: f0 = %d, f2 = NaN : expected / observed = 3 /%x\n", i, (result & 0xc00) >> 10); return(-1); } } return(0);}branching(){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -