home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / cpu.zoo / cpu.2 < prev    next >
Internet Message Format  |  1989-08-18  |  9KB

  1. From santra!kth!sunic!mcvax!uunet!cs.utexas.edu!csd4.csd.uwm.edu!mailrus!jarvis.csri.toronto.edu!utgpu!utzoo!mnetor!tmsoft!mshiels Fri Aug 18 10:31:35 EET DST 1989
  2. Article 7095 of comp.sys.ibm.pc:
  3. Path: chyde!santra!kth!sunic!mcvax!uunet!cs.utexas.edu!csd4.csd.uwm.edu!mailrus!jarvis.csri.toronto.edu!utgpu!utzoo!mnetor!tmsoft!mshiels
  4. >From: mshiels@tmsoft.uucp (Michael A. Shiels)
  5. Newsgroups: comp.sys.ibm.pc
  6. Subject: CPU Identification 2 of 4
  7. Message-ID: <1989Aug16.110529.340@tmsoft.uucp>
  8. Date: 16 Aug 89 11:05:29 GMT
  9. Reply-To: mshiels@tmsoft.UUCP (Michael A. Shiels)
  10. Followup-To: comp.sys.ibm.pc
  11. Organization: MaS Network Software and Consulting
  12. Lines: 184
  13.  
  14.  
  15.          TITLE   CPU - PRINT INTEL CPU TYPE ON CONSOLE
  16. ; PGMID.  CPU.ASM
  17. ; AUTHOR. UNKNOWN INTEL EMPLOYEE (MASM V5.0 MAINLINE ADDED BY DON HIGGINS)
  18. ;                                (COMPUSERVE 73047,1113)
  19. ; DATE.   11/13/87.
  20. ;
  21. ; Fixed 05/25/88 73710,3667 TRT
  22. ; CMP     AX,386 changed to CMP    AX,386H
  23. ; this change allows this program to identify '386 machines
  24. ; much more accurately.
  25. DATA     SEGMENT PUBLIC
  26. system_type_opt db IBM  ;IS THERE A BYTE IN ROM BIOS FOR THIS ?
  27. IBM      equ 0
  28. NC_type  equ 1
  29. MSGNC    DB    'CPU NON COMPATIBLE$'
  30. MSG086   DB    'CPU IS 8086/8088$'
  31. MSG186   DB    'CPU IS 80186$'
  32. MSG286   DB    'CPU IS 80286$'
  33. MSG386   DB    'CPU IS 80386$'
  34. DATA     ENDS
  35. STACK    SEGMENT STACK
  36.          DB      200 DUP(?)
  37. STACK    ENDS
  38. CODE     SEGMENT PUBLIC
  39.          ASSUME  CS:CODE,DS:DATA
  40.          PUBLIC  CPU
  41. CPU      LABEL   NEAR
  42.          MOV     AX,DATA
  43.          MOV     DS,AX
  44.          CALL    get_cpu_type
  45.          CMP     AX,86H
  46.          JE      CPU086
  47.          CMP     AX,186H
  48.          JE      CPU186
  49.          CMP     AX,286H
  50.          JE      CPU286
  51.          CMP     AX,386H
  52.          JE      CPU386
  53. CPUNC    LABEL   NEAR
  54.          MOV     DX,OFFSET MSGNC
  55. WTO      LABEL   NEAR
  56.          MOV     AH,9
  57.          INT     21H
  58.          MOV     AH,4CH
  59.          INT     21H
  60. CPU086   LABEL   NEAR
  61.          MOV     DX,OFFSET MSG086
  62.          JMP     WTO
  63. CPU186   LABEL   NEAR
  64.          MOV     DX,OFFSET MSG186
  65.          JMP     WTO
  66. CPU286   LABEL   NEAR
  67.          MOV     DX,OFFSET MSG286
  68.          JMP     WTO
  69. CPU386   LABEL   NEAR
  70.          MOV     DX,OFFSET MSG386
  71.          JMP     WTO
  72. ;-----------------------------------------------------------------------------;
  73. ;                                                                             ;
  74. ;   Procedure Name:   get_cpu_type                                            ;
  75. ;           Author:   Anonymous Intel Employee                                ;
  76. ;             Date:   7/7/87                                                  ;
  77. ;      Description:   This procedure returns the hex value of the processor   ;
  78. ;                     type to the calling procedure.  It is able to identify  ;
  79. ;                     the 8086, 80186, 80286, 80386.                          ;
  80. ;                                                                             ;
  81. ;     Parms Passed:   None                                                    ;
  82. ;                                                                             ;
  83. ;   Results/Status                                                            ;
  84. ;         Returned:   AX = hex digits for the CPU type.                       ;
  85. ;                                                                             ;
  86. ; Calling Sequence:   CALL      get_CPU_type                                  ;
  87. ;                                                                             ;
  88. ;        Called By:   delete_defective_expanded_memory_pages                  ;
  89. ;                                                                             ;
  90. ;            Calls:   Nothing                                                 ;
  91. ;                                                                             ;
  92. ;        Registers                                                            ;
  93. ;         Modified:   AX                                                      ;
  94. ;                                                                             ;
  95. ;          Globals                                                            ;
  96. ;        Modified/                                                            ;
  97. ;       Referenced:   None                                                    ;
  98. ;                                                                             ;
  99. ;-----------------------------------------------------------------------------;
  100. get_cpu_type                PROC        NEAR
  101. PUBLIC                        get_cpu_type
  102.  
  103.         ;---------------------------------------------------------------------;
  104.         ;   If the system type is non-compatible then                         ;
  105.         ;     return (cpu type = 0)                                           ;
  106.         ;---------------------------------------------------------------------;
  107.         CMP                WORD PTR system_type_opt, NC_type
  108.         JNE                determine_cpu_type
  109.         XOR                AX, AX
  110.         RET
  111.  
  112. determine_cpu_type:
  113.         ;---------------------------------------------------------------------;
  114.         ;   Save registers used.                                              ;
  115.         ;---------------------------------------------------------------------;
  116.         PUSHF
  117.  
  118.         ;---------------------------------------------------------------------;
  119.         ;   Pop a zero into the FLAGS register and attempt to set bits 15-12  ;
  120.         ;   to zero.                                                          ;
  121.         ;   If bits 15-12 = 0 then                                            ;
  122.         ;     the cpu type is an 8018X or an 808X.                            ;
  123.         ;---------------------------------------------------------------------;
  124.         XOR                AX, AX
  125.         PUSH               AX
  126.         POPF
  127.         PUSHF
  128.         POP                AX
  129.         AND                AX, 0F000h
  130.         CMP                AX, 0F000h
  131.         JNE                check_for_80286
  132.  
  133. check_for_8086_80186:
  134.         ;---------------------------------------------------------------------;
  135.         ;   Cpu type is an 8086 or 80186.                                     ;
  136.         ;   Shift a pattern of all ones left 33 times.                        ;
  137.         ;   If shift result = 0 then                                          ;
  138.         ;     cpu type is a 80186                                             ;
  139.         ;   else                                                              ;
  140.         ;     cpu type is a 8086                                              ;
  141.         ;---------------------------------------------------------------------;
  142.         PUSH               CX
  143.         MOV                AX, 0FFFFh
  144.         MOV                CL, 33
  145.         SHL                AX, CL
  146.         POP                CX
  147.         JNZ                check_for_80186
  148.  
  149. check_for_8086:
  150.         ;---------------------------------------------------------------------;
  151.         ;   Cpu type is an 8086.                                              ;
  152.         ;---------------------------------------------------------------------;
  153.         MOV                AX, 86h
  154.         POPF
  155.         RET
  156.  
  157. check_for_80186:
  158.         ;---------------------------------------------------------------------;
  159.         ;   Cpu type is an 80186.                                             ;
  160.         ;---------------------------------------------------------------------;
  161.         MOV                AX, 186h
  162.         POPF
  163.         RET
  164.  
  165. check_for_80286:
  166.         ;---------------------------------------------------------------------;
  167.         ;   Attempt to set FLAG bits 14-12 (NT and IOPL bits).                ;
  168.         ;---------------------------------------------------------------------;
  169.         MOV                AX, 7000h
  170.         PUSH               AX
  171.         POPF
  172.         PUSHF
  173.         POP                AX
  174.  
  175.         ;---------------------------------------------------------------------;
  176.         ;   If NT & IOPL bits are not set then                                ;
  177.         ;     cpu type is and 80286                                           ;
  178.         ;---------------------------------------------------------------------;
  179.         AND                AX, 7000h
  180.         JNZ                check_for_80386
  181.         MOV                AX, 286h
  182.         POPF
  183.         RET
  184.  
  185. check_for_80386:
  186.         ;---------------------------------------------------------------------;
  187.         ;   Cpu type is an 80386                                              ;
  188.         ;---------------------------------------------------------------------;
  189.         MOV                AX, 386h
  190.         POPF
  191.         RET
  192.  
  193. get_cpu_type                ENDP
  194. CODE    ENDS
  195.         END    CPU
  196.                                              
  197.  
  198.  
  199.