www.pudn.com > 测试 CPU和NDP 的型号.zip > TEST.C
/*********************************************************************** * * TEST.C - a Quick 'n Dirty program to demonstrate use of the * function, chips(), which identifies CPU and NDP * (math coprocessor) type at runtime..... * * Make sure you load the project file TEST.PRJ and * that your are compiling under the Small, Tiny or * Compact memory models. * * pat shea - Bethlehem, PA * Henrik Schmiediche - CS, TX * **********************************************************************/ #include#include #include int chips( void ); /* this is the guy that duz all the work for us...... don't forget to LINK him in !! */ void main() { char str_CPU[16], str_NDP[16]; /* to hold screen messages */ int i = chips(); /* get the int return that tells the CPU and NDP (math coprocessor) types */ /*********************************************************************** * This first switch gives us the high order digits off the return from * chips() and determines the CPU type. **********************************************************************/ switch( i / 10 ) { case 8: strcpy( str_CPU, "8088/8086" ); break; case 18: strcpy( str_CPU, "80188/80186" ); break; case 20: strcpy( str_CPU, "NEC V20/V30" ); break; case 28: strcpy( str_CPU, "80286" ); break; case 38: strcpy( str_CPU, "80386" ); break; default: printf( "\n\t\tCPU test SNAFU'd! I'm bailin' out.\n\n" ); exit( 99 ); } /********************************************************************** * Now.... let's figger out what kinda NDP we got by stripping off * all the high end digits leaving us with just the low order guy * with all the NDP info..... **********************************************************************/ switch( i % 10 ) { case 0: strcpy( str_NDP, "NO CHIP" ); break; case 1: strcpy( str_NDP, "an 8087" ); break; case 2: strcpy( str_NDP, "an 80287" ); break; case 3: strcpy( str_NDP, "an 80387" ); break; default: printf( "\n\t\tNDP test SNAFU'd! I'm bailin' out.\n\n" ); exit( 99 ); } printf( "\nI see an %s in here as the CPU\n", str_CPU ); printf( "and %s for a math coprocessor.\n", str_NDP ); }