📄 fputest.c
字号:
int i; unsigned long result; clear_regs(0); result = get_fsr(); /* was 0xF0700000 - changed to ignore unused bits 29,28 and reserved bits 20,21 (for future compatibility) */ result = result & 0xC0400000; /* set all exception bits to zero */ set_fsr(result); error_ok = 1; for (i = 0; i < 64; i++) { if (result = branches(0, val[i].floatsingle, 0x7f800400)) { send_message(0, ERROR, "\nFBU failed. result = %x\n", result); return(-1); } if (result = branches(1, val[i+1].floatsingle, val[i].floatsingle)) { send_message(0, ERROR, "\nFBG failed: f0 = %x, f2 = %x.\n", i+1, i); return(-1); } if (result = branches(2, val[i].floatsingle, 0x7f800400)) { send_message(0, ERROR, "\nFBUG (unordered) failed.\n"); return(-1); } if (result = branches(2, val[i+1].floatsingle, val[i].floatsingle)) { send_message(0, ERROR, "\nFBUG (greater) failed: f0 = %x, f2 = %x.\n", i+1, i); return(-1); } if (result = branches(3, val[i].floatsingle,val[i+1].floatsingle)) { send_message(0, ERROR, "\nFBL failed: f0 = %x, f2 = %x.\n", i, i+1); return(-1); } if (result = branches(4, val[i].floatsingle, 0x7f800400)) { send_message(0, ERROR, "\nFBUL (unordered) failed.\n"); return(-1); } if (result = branches(4,val[i].floatsingle,val[i+1].floatsingle)) { send_message(0, ERROR, "\nFBUL (Less) failed: f0 = %x, f2 = %x.\n", i, i+1); return(-1); } if (result = branches(5, val[i].floatsingle,val[i+1].floatsingle)) { send_message(0, ERROR, "\nFBLG (Less) failed: f0 = %x, f2 = %x.\n", i, i+1); return(-1); } if (result = branches(5, val[i+1].floatsingle, val[i].floatsingle)) { send_message(0, ERROR, "\nFBLG (Greater) failed: f0 = %x, f2 = %x.\n", i+1, i); return(-1); } if (result = branches(6, val[i].floatsingle,val[i+1].floatsingle)) { send_message(0, ERROR, "\nFBNE failed: f0 = %x, f2 = %x.\n", i, i+1); return(-1); } if (result = branches(7, val[i].floatsingle,val[i].floatsingle)) { send_message(0, ERROR, "\nFBE failed : f0 = %x, f2 = %x.\n", i, i); return(-1); } if (result = branches(8, val[i].floatsingle, 0x7f800400)) { send_message(0, ERROR, "\nFBUE (unordered) failed.\n"); return(-1); } if (result = branches(8, val[i].floatsingle,val[i].floatsingle)) { send_message(0, ERROR, "\nFBUE (equal) failed : f0 = %x, f2 = %x.\n", i, i); return(-1); } if (result = branches(9, val[i].floatsingle,val[i].floatsingle)) { send_message(0, ERROR, "\nFBGE (equal) failed : f0 = %x, f2 = %x.\n", i, i); return(-1); } if (result = branches(9, val[i+1].floatsingle, val[i].floatsingle)) { send_message(0, ERROR, "\nFBGE (greater) failed: f0 = %x, f2 = %x.\n", i+1, i); return(-1); } if (result = branches(10, val[i].floatsingle, 0x7f800400)) { send_message(0, ERROR, "\nFBUGE (unordered) failed.\n"); return(-1); } if (result = branches(10, val[i].floatsingle,val[i].floatsingle)) { send_message(0, ERROR, "\nFBUGE (equal) failed : f0 = %x, f2 = %x.\n", i, i); return(-1); } if (result = branches(10, val[i+1].floatsingle, val[i].floatsingle)) { send_message(0, ERROR, "\nFBUGE (greater) failed: f0 = %x, f2 = %x.\n", i+1, i); return(-1); } if (result = branches(11, val[i].floatsingle,val[i+1].floatsingle)) { send_message(0, ERROR, "\nFBLE (Less) failed: f0 = %x, f2 = %x.\n", i, i+1); return(-1); } if (result = branches(11, val[i].floatsingle,val[i].floatsingle)) { send_message(0, ERROR, "\nFBLE (equal) failed : f0 = %x, f2 = %x.\n", i, i); return(-1); } if (result = branches(12, val[i].floatsingle, 0x7f800400)) { send_message(0, ERROR, "\nFBULE (unordered) failed.\n"); return(-1); } if (result = branches(12, val[i].floatsingle,val[i+1].floatsingle)) { send_message(0, ERROR, "\nFBULE (Less) failed: f0 = %x, f2 = %x.\n", i, i+1); return(-1); } if (result = branches(12, val[i].floatsingle,val[i].floatsingle)) { send_message(0, ERROR, "\nFBULE (equal) failed : f0 = %x, f2 = %x.\n", i, i); return(-1); } if (result = branches(13, val[i].floatsingle,val[i+1].floatsingle)) { send_message(0, ERROR, "\nFBO failed: f0 = %x, f2 = %x.\n", i, i+1); return(-1); } if (result = branches(14, val[i].floatsingle,val[i+1].floatsingle)) { send_message(0, ERROR, "\nFBA failed: f0 = %x, f2 = %x.\n", i, i+1); return(-1); } if (result = branches(15, val[i].floatsingle,val[i+1].floatsingle)) { send_message(0, ERROR, "\nFBN failed: f0 = %x, f2 = %x.\n", i, i+1); return(-1); } } error_ok = 0; return(0);}no_branching(){ int i; unsigned long result; clear_regs(0); result = get_fsr(); /* was 0xF0700000 - changed to ignore unused bits 29,28 and reserved bits 20,21 (for future compatibility) */ result = result & 0xC0400000; /* set all exception bits to zero */ set_fsr(result); error_ok = 1; for (i = 0; i < 64; i++) { if (!(result = branches(0, val[i].floatsingle, val[i].floatsingle))) { send_message(0, ERROR, "\nFBU failed.\n"); return(-1); } if (!(result = branches(1,val[i].floatsingle, val[i].floatsingle))) { send_message(0, ERROR, "\nFBG failed: f0 = %x, f2 = %x.\n", i, i); return(-1); } if (!(result = branches(2,val[i].floatsingle, val[i].floatsingle))) { send_message(0, ERROR, "\nFBUG failed: f0 = %x, f2 = %x.\n", i, i); return(-1); } if (!(result = branches(3,val[i].floatsingle, val[i].floatsingle))) { send_message(0, ERROR, "\nFBLfailed: f0 = %x, f2 = %x.\n", i, i); return(-1); } if (!(result = branches(4, val[i].floatsingle, val[i].floatsingle))) { send_message(0, ERROR, "\nFBUL failed: f0 = %x, f2 = %x.\n", i, i); return(-1); } if (!(result = branches(5, val[i].floatsingle, val[i].floatsingle))) { send_message(0, ERROR, "\nFBLG failed: f0 = %x, f2 = %x.\n", i, i); return(-1); } if (!(result = branches(6, val[i].floatsingle, val[i].floatsingle))) { send_message(0, ERROR, "\nFBNE failed: f0 = %x, f2 = %x.\n", i, i); return(-1); } if (!(result = branches(7, val[i+1].floatsingle, val[i].floatsingle))) { send_message(0, ERROR, "\nFBE failed: f0 = %x, f2 = %x.\n", i+1 , i); return(-1); } if (!(result = branches(8, val[i+1].floatsingle, val[i].floatsingle))) { send_message(0, ERROR, "\nFBUE failed: f0 = %x, f2 = %x.\n", i+1 , i); return(-1); } if (!(result = branches(9, val[i].floatsingle, val[i+1].floatsingle))) { send_message(0, ERROR, "\nFBGEfailed: f0 = %x, f2 = %x.\n", i, i+1 ); return(-1); } if (!(result = branches(10, val[i].floatsingle,val[i+1].floatsingle))) { send_message(0, ERROR, "\nFBUGEfailed: f0 = %x, f2 = %x.\n", i, i+1 ); return(-1); } if (!(result = branches(11, val[i+1].floatsingle, val[i].floatsingle))) { send_message(0, ERROR, "\nFBLE failed: f0 = %x, f2 = %x.\n", i+1 , i); return(-1); } if (!(result = branches(12, val[i+1].floatsingle, val[i].floatsingle))) { send_message(0, ERROR, "\nFBULE failed: f0 = %x, f2 = %x.\n", i+1 , i); return(-1); } if (!(result = branches(13, val[i].floatsingle, 0x7f800400))) { send_message(0, ERROR, "\nFBO failed.\n"); return(-1); } } error_ok = 0; return(0);}compare_sp_except(){ int i; unsigned long result; clear_regs(0); result = get_fsr(); result = result | 0xF800000; set_fsr(result); error_ok = 1; for (i = 0; i < 200; i++) { result = cmp_s_ex(val[i].floatsingle, 0x7fbfffff); if (!trap_flag) { send_message(0, ERROR, "\nfcmpxs failed: Exception did not occur. fsr = %x\n", result); return(-1); } } error_ok = 0; return(0);} compare_dp_except(){ int i; unsigned long result; clear_regs(0); result = get_fsr(); result = result | 0xF800000; set_fsr(result); error_ok = 1; for (i = 0; i < 199; i++) { result = cmp_d_ex(val[i].floatdouble, 0x7ff00080); if (!trap_flag) { send_message(0, ERROR, "\nfcmpxd failed: Exception did not occur. fsr = %x\n", result); return(-1); } } error_ok = 0; return(0); } /* * Nack test : In this test the program will create all * possible floating point traps and * checks whether it occured or not. */fpu_nack_test(){ unsigned long fsr_status; error_ok = 1; fsr_status = get_fsr(); fsr_status = fsr_status | 0xF800000; /* set the TEM bits */ set_fsr(fsr_status); donot_dq = 0x0; trap_flag = 0x0; /* unset the trap flag */ /* Test that there should not be any exception */ wadd_sp(0x3f800000, 0x3f800000); if (trap_flag) { send_message(0, ERROR, "\nError: Bus error occured. ftt = %x ", (fsr_at_trap & 0x1c000) >> 14); ftt_decode(fsr_at_trap); return(-1); } /* now test the IEEE exception */ trap_flag = 0x0; /* unset the trap flag */ wdiv_sp(0x3f800000, 0x00000); if (!trap_flag) { send_message(0, ERROR, "\nError: Bus error did not occur(IEEE exception). ftt = %x", (fsr_at_trap & 0x0001C000) >> 14); ftt_decode(fsr_at_trap); return(-1); }/* * Second level: Confirm that the ftt bits in the FSR are set correctly * *** Note this is not valid with SunOs >= 4.0 because * the OS clears the FSR on an exception. *//*DISABLED - BDS * * if ((fsr_at_trap & 0x1C000) != 0x4000) { * send_message(0, ERROR, "\nError: ftt bits expected / observed = 1 / %x", * (fsr_at_trap & 0x0001C000) >> 14); * ftt_decode(fsr_at_trap); * return(-1); * } */ /* test for unfinished exception */ trap_flag = 0x0; wadd_sp(0x7fbfffff, 0x0); if (!trap_flag) { send_message(0, ERROR, "\nError: Bus error did not occur(Unfinished exception). ftt = %x", (fsr_at_trap & 0x0001C000) >> 14); ftt_decode(fsr_at_trap); return(-1); } wadd_sp(1,1); /* clear the execption error *//* * Second level: Confirm that the ftt bits in the FSR are set correctly * *** Note this is not valid with SunOs >= 4.0 because * the OS clears the FSR on an exception. *//*DISABLED - BDS * if ((fsr_at_trap & 0x1c000) != 0x8000) { * send_message(0, ERROR, "\nError: ftt bits expected / observed = 2 / %x\n", * (fsr_at_trap & 0x0001c000) >> 14); * ftt_decode(fsr_at_trap); * return(-1); * } */ wadd_sp(1,1); /* clear the execption error */ set_fsr(0x0); error_ok = 0; return(0);} /* * retgisters.c * * The following routine writes the given patterns to all the registers * and reads it back. * The following routine tests all the possible values given for single * precision numbers. * */registers_three(){ int i,j,k,l; unsigned long result, value; for (i = 0; i < 2; i++) { for (j = 1; j < 255; j++) { for (k = 0; k < 23; k++) { for (l = 0; l < 32; l++) { value = (i << 31) | (j << 23) | (1 << k); if ((result = register_test(i, value)) != value) { send_message(0, ERROR, "\nregister read/write failed : reg = %d, expected / observed = %x / %x\n", l, value, result); return(-1); } } } } } return(0);} /* * The following routine tests rotating ones to the registers */ registers_two(){ int i,j; unsigned long result, value; for (j = 0; j < 32; j++) { for (i = 0; i < 32; i++) { value = (1 << i); if ((result = register_test(j, value)) != value) { send_message(0, ERROR, "\nregister test-2 read/write failed : reg = %d, expected / observed = %x / %x\n", j, value, result); return(-1); } } } return(0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -