/* file "test_program.c" * Tests the operation of assy language routine to convert PowerPC TimeBase * values from integer to DP floating point values. Chuck Corley 981214 * Modified: 000327 MRR */ #include #include "Excimer.h" /* File of Excimer board-specific constants */ #include "Exercise.h" /* File of common typedefs for this exercise */ #include "dinkusr.h" #define printf dink_printf struct TB_View conversion_test(int, int, double); /* Given bus freq, returns time in seconds. */ void main(void) { set_up_transfer_base(); int i, MAX_EXAMPLES; struct Test_struct Example[] = { /* Consider - Case1: Z<11; Case2: Z>=11; Case3: z<11; Case4: z>=11; Case5: Z=z=32; */ /* Case5: All leading zeroes. */ { 0x00000000, 0x00000000, 0x00000000, 0x00000000}, /* Case4: Single one to treat as implied bit. Move from TB[32+31] to DPFP[11]. */ { 0x00000000, 0x00000001, 0x3FF00000, 0x00000000}, /* Case4: Single one to treat as implied bit. Move from TB[32+30] to DPFP[11]. */ { 0x00000000, 0x00000002, 0x40000000, 0x00000000}, /* Case4: Single one to treat as implied bit. Move from TB[32+12] to DPFP[11]. */ { 0x00000000, 0x00080000, 0x41200000, 0x00000000}, /* Case4: FRACTION starting in TB[32+12]. Move to DPFP[12:31]. */ { 0x00000000, 0x00180000, 0x41380000, 0x00000000}, /* Case3: FRACTION starting in TB[32+11]. Move to DPFP[12:32]. Check DPFP[32]=1. */ { 0x00000000, 0x00380001, 0x414C0000, 0x80000000}, /* Case3: FRACTION (One sec) starts TB[32+9]. Move to DPFP[12:34]. DPFP[32:34]=6? */ { 0x00000000, 0x00FE502B, 0x416FCA05, 0x60000000}, /* Case3: FRACTION in TB[33:63]. FPU[12:31]=TBL[1:20]. FPL[0:10]=TBL[21:31]. */ { 0x00000000, 0xC0000401, 0x41E80000, 0x80200000}, /* Case2: FRACTION-TB[31:63]. FPU[12]=TBU[31]. FPU[13:31]=TBL[0:18]. FPL[0:12]=TBL[19:31].*/ { 0x00000003, 0x40005001, 0x420A0002, 0x80080000}, /* Case1: FRACTION-TB[11:63]. FPU[12:31]=TBU[11:30]. FPU[0]=TBU[31]. FPL[1:31]=TBL[0:30].*/ { 0x00380001, 0x40010005, 0x434C0000, 0xA0008002}, /* Case1: TB[1:63]. FPU[12:31]=TBU[1:20]. FPL[0:10]=TBU[21:31]. FPL[11:31]=TBL[0:20].*/ { 0xFEDCBA98, 0x76543210, 0x43EFDB97, 0x530ECA86}, }; struct Test_struct Result; MAX_EXAMPLES = sizeof(Example) / sizeof(Example[0]); for (i=0; i< MAX_EXAMPLES; i++) { /* These printf formats are for the restrictive dink_print routine. */ printf("TBU= %x ", Example[i].TB_GPR_View.TBU_View); printf("TBL= %x ", Example[i].TB_GPR_View.TBL_View); Result.TB_FP_test.TB_FPasGPR_View = conversion_test (Example[i].TB_GPR_View.TBU_View, \ Example[i].TB_GPR_View.TBL_View, TICS_PER_SEC); if ((Result.TB_FP_test.TB_FPasGPR_View.TBU_View != \ Example[i].TB_FP_test.TB_FPasGPR_View.TBU_View) || \ (Result.TB_FP_test.TB_FPasGPR_View.TBL_View != \ Example[i].TB_FP_test.TB_FPasGPR_View.TBL_View)) \ printf(" ERROR!\n"); printf("FPU= %x ", Result.TB_FP_test.TB_FPasGPR_View.TBU_View); printf("FPL= %x\n", Result.TB_FP_test.TB_FPasGPR_View.TBL_View); /* This is not useful on Excimer because we can't print the floating point result. It is a useful check in CodeWarrior on the Mac. CJC*/ /* Result.TB_FP_test.TB_FP_View = float_test(Example[i].TB_GPR_View.TBU_View, Example[i].TB_GPR_View.TBL_View, TICS_PER_SEC); printf("FPR = %4.2e \n", Result.TB_FP_test.TB_FP_View); */ }; return; }