home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / progasm / cputype0.arj / CPUTYPE.ASM next >
Encoding:
Assembly Source File  |  1990-08-01  |  1.0 KB  |  51 lines

  1. ;_ cputype.asm   Sat Jan 14 1989   Modified by: Walter Bright */
  2.  
  3. include    macros.asm
  4.  
  5.     begcode    CPUTYPE
  6.  
  7. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8. ; Determine which CPU is running.
  9. ; Placed into public domain by Compaq Computers.
  10. ; Do not call from protected mode.
  11. ;    int cputype(void);
  12. ; Returns:
  13. ;    0    8088/8086/V20
  14. ;    1    80186
  15. ;    2    80286
  16. ;    3    80386
  17.  
  18.     c_public cputype
  19. func    cputype
  20.     pushf
  21.     clr    AX
  22.     push    AX
  23.     popf        ;try forcing flag word to all 0
  24.     pushf
  25.     pop    AX    ;retrieve them for testing
  26.     and    AH,0F0h
  27.     .if    AH ne 0F0h, L2    ;it's a 286 or 386
  28.     ;Distinguish between 8088/8086 and 80186
  29.     clr    AX
  30.     push    SP        ;is SP pushed before or after it's decremented?
  31.     pop    BX
  32.     .if    BX ne SP,L1    ;it's an 8088/8086
  33.     jmps    L3        ;it's an 80186
  34.  
  35. L2:    mov    AX,0F000h
  36.     push    AX        ;try to force high bits on in flags
  37.     popf
  38.     pushf
  39.     pop    AX        ;AX = what was actually stored
  40.     and    AH,0F0h
  41.     mov    AX,2
  42.     jz    L1        ;no, it's a 286
  43. L3:    inc    AX        ;it's a 186 or 386
  44. L1:    popf            ;original flags
  45.     ret
  46. c_endp    cputype
  47.  
  48.     endcode    CPUTYPE
  49.  
  50.     end
  51.