home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / FC20C.ZIP / EQUIP.C < prev    next >
C/C++ Source or Header  |  1990-08-20  |  2KB  |  71 lines

  1. /*
  2.  * Program to display the equipment configuration installed in
  3.  * an IBM/PC or compatable system.
  4.  *
  5.  * This demonstrates the use of inline assembly language routines,
  6.  * which are used to obtain information from the IBM/PC BIOS.
  7.  *
  8.  * Copyright 1989,1990 Dave Dunfield
  9.  * All rights reserved.
  10.  */
  11. #include \mc\stdio.h
  12.  
  13. /* Video adapter display text */
  14.     char *ivmode[] = { "Unknown", "Color-40", "Color-80", "Monochrome" };
  15.  
  16. /*
  17.  * Main program to display the equipment installed in an IBM/PC
  18.  */
  19. main()
  20. {
  21.     int equip, hdrives, i;
  22.  
  23.     equip = get_equip();
  24.     hdrives = 0;
  25.     for(i=0x80; i < (0x80+26); ++i) {
  26.         if(!test_drive(i))
  27.             ++hdrives; }
  28.     printf("Base system memory=%uK\n", get_mem());
  29.     printf("Math co-processor%sinstalled\n", (equip & 2) ? " " : " not ");
  30.     printf("Game adaptor%sinstalled\n", (equip & 0x1000) ? " " : " not ");
  31.     printf("Startup video is %s\n", ivmode[(equip >> 4) & 3]);
  32.     printf("%u Floppy disk drive(s)\n", (equip & 1) && (((equip >> 6) & 3) + 1));
  33.     printf("%u Hard disk drive(s)\n", hdrives);
  34.     printf("%u Serial port(s)\n", (equip >> 9) & 7);
  35.     printf("%u Parallel port(s)\n", (equip >> 14) & 3);
  36. }
  37.  
  38. /*
  39.  * Get the equipment configuration from BIOS
  40.  */
  41. get_equip()
  42. { ;
  43. #asm
  44.         INT        11h            ; Get equipment
  45. #endasm
  46. }
  47.  
  48. /*
  49.  * Get size of installed memory from BIOS
  50.  */
  51. get_mem()
  52. { ;
  53. #asm
  54.         INT        12h            ; Get memory size
  55. #endasm
  56. }
  57.  
  58. /*
  59.  * Test for existance of a hard drive
  60.  */
  61. test_drive(drive)
  62. { ;
  63. #asm
  64.         MOV        DL,4[BP]    ; Get drive id
  65.         MOV        AH,10h        ; Drive status function
  66.         INT        13h            ; Ask BIOS
  67.         MOV        AL,AH        ; Get value
  68.         XOR        AH,AH        ; Zero high
  69. #endasm
  70. }
  71.