home *** CD-ROM | disk | FTP | other *** search
/ Informática Multimedia: Special Programming / INFPROG.iso / asm / test.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-09-01  |  2.6 KB  |  77 lines

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