Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.5 KiB

  1. chkcpu macro
  2. jmp begn
  3. msg db 13,10,"This copy of MS-DOS will run only on an 8086",13,10
  4. db "or 8088 CPU based computer. This computer is not ",13,10
  5. db "based on an 8086 or 8088 CPU. ",13,10
  6. db 13,10,"Insert a copy of the appropriate MS-DOS system disk ",13,10
  7. db "and press any key to re-boot.",13,10,0
  8. begn:
  9. ;------GET_CPU_TYPE------------------------------------------------------------May, 88 by M.Williamson
  10. ; Returns: AX = 0 if 8086 or 8088
  11. ; = 1 if 80286
  12. ; = 2 if 80386
  13. ;
  14. pushf
  15. push bx ; preserve bx
  16. xor bx, bx ; init bx to zero
  17. xor ax,ax ; 0000 into AX
  18. push ax ; put it on the stack...
  19. popf ; ...then shove it into the flags
  20. pushf ; get it back out of the flags...
  21. pop ax ; ...and into ax
  22. and ax,0F000h ; mask off high four bits
  23. cmp ax,0F000h ; was it all 1's?
  24. je scpu_8086 ; aye; it's an 8086 or 8088
  25. mov ax,0F000h ; now try to set the high four bits..
  26. push ax
  27. popf
  28. pushf
  29. pop ax ; ...and see what happens
  30. and ax,0F000h ; any high bits set ?
  31. jz scpu_286 ; nay; it's an 80286
  32. scpu_386: ; bx starts as zero
  33. inc bx ; inc twice if 386
  34. scpu_286: ; just inc once if 286
  35. inc bx
  36. scpu_8086: ; don't inc at all if 086
  37. mov ax, bx ; put CPU type value in ax
  38. pop bx ; restore original bx
  39. popf
  40. cmp ax, 0000
  41. je cpu_ok
  42. push cs
  43. pop ds
  44. mov si, offset msg
  45. prnt: lodsb
  46. or al, al
  47. jz prnt_done
  48. mov ah, 14
  49. mov bx, 7
  50. int 10h
  51. jmp prnt
  52. prnt_done:
  53. xor ah, ah
  54. int 16h
  55. int 19h
  56. cpu_ok:
  57. endm
  58.