home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / chipsc / chipstc / test.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-09  |  2.8 KB  |  82 lines

  1. /***********************************************************************
  2.  *
  3.  *  TEST.C - a Quick 'n Dirty program to demonstrate use of the
  4.  *             function, chips(), which identifies CPU and NDP
  5.  *             (math coprocessor) type at runtime.....
  6.  *
  7.  *             Make sure you load the project file TEST.PRJ and
  8.  *             that your are compiling under the Small, Tiny or
  9.  *             Compact memory models.
  10.  *
  11.  *                                     pat shea - Bethlehem, PA
  12.  *                                     Henrik Schmiediche - CS, TX
  13.  *
  14.  **********************************************************************/
  15.  
  16. #include    <stdio.h>
  17. #include    <stdlib.h>
  18. #include    <string.h>
  19.  
  20.  
  21. int chips( void );     /* this is the guy that duz all the work for
  22.                             us...... don't forget to LINK him in !!   */
  23. void main()
  24. {
  25.     char str_CPU[16], str_NDP[16];  /* to hold screen messages        */
  26.  
  27.     int i = chips();   /* get the int return that tells the CPU and
  28.                             NDP (math coprocessor) types              */
  29.  
  30. /***********************************************************************
  31.  * This first switch gives us the high order digits off the return from
  32.  *   chips() and determines the CPU type.
  33.  **********************************************************************/
  34.  
  35.     switch( i / 10 ) {
  36.         case  8:
  37.             strcpy( str_CPU, "8088/8086" );
  38.             break;
  39.         case 18:
  40.             strcpy( str_CPU, "80188/80186" );
  41.             break;
  42.         case 20:
  43.             strcpy( str_CPU, "NEC V20/V30" );
  44.             break;
  45.         case 28:
  46.             strcpy( str_CPU, "80286" );
  47.             break;
  48.         case 38:
  49.             strcpy( str_CPU, "80386" );
  50.             break;
  51.         default:
  52.             printf( "\n\t\tCPU test SNAFU'd!  I'm bailin' out.\n\n" );
  53.             exit( 99 );
  54.     }
  55.  
  56. /**********************************************************************
  57.  * Now.... let's figger out what kinda NDP we got by stripping off
  58.  *   all the high end digits leaving us with just the low order guy
  59.  *   with all the NDP info.....
  60.  **********************************************************************/
  61.  
  62.     switch( i % 10 ) {
  63.         case 0:
  64.             strcpy( str_NDP, "NO CHIP" );
  65.             break;
  66.         case 1:
  67.             strcpy( str_NDP, "an 8087" );
  68.             break;
  69.         case 2:
  70.             strcpy( str_NDP, "an 80287" );
  71.             break;
  72.         case 3:
  73.             strcpy( str_NDP, "an 80387" );
  74.             break;
  75.         default:
  76.             printf( "\n\t\tNDP test SNAFU'd!  I'm bailin' out.\n\n" );
  77.             exit( 99 );
  78.     }
  79.     printf( "\nI see an %s in here as the CPU\n", str_CPU );
  80.     printf( "and %s for a math coprocessor.\n", str_NDP );
  81. }
  82.