
                        
       Virus Magazine   Box 10, Kiev 148, Ukraine       IV   1996
            
                             
                                            
                                 
           
          (C) Copyright, 1994-96, by STEALTH group WorldWide, unLtd.

=============================================================================

    ͻ
                                
          by MrStrange     
    ͼ

        砨,  ணࠬ 室 
 ⨯ ,    ࠡ⠥.  80286 
   ,    8086,   
 ⥫쭮 㪮  .  386  ⫠
 ॣ,  ⠪  ᯮ짮 for best results.
  ⫠ ॣ ⠩  IV5, 䠩 iv_5.03b.  
 ᠭ,   ⮣, ⮡ ᯮ  80386
 筮 墠 뢠 6 (INVALID OPCODE) 
 믮  , ன   286 (-,
 ᯮ饥 32- ॣ, ਬ). ᫨  ⮬
 믮 뢠 INVALID OPCODE,   
 386-.   ⠪ ⮤  ᮢᥬ ४⥭.   ⮬,
  뢠 6  ⪥ ᯮ  
  ⮫쪮    ࠬ 286  . 
 ந室  8086  80186   .  뢠 ᯮ짮
 6- 뢠   設 XT, ⠬ ணࠬ 
 訫  樨 push 1, 6- 뢠 砫.
 -⠪  ⥫ , ⮡ - ᢥ⨫ 
 ⭮⥫쭮 ॠ樨 8086  80186   .

       ⮣, ⮡ । ⨯ , 筮
 ,   ⫨砥  ।⢥.  ⫨砥 186
   㣮 訩   8086?   80x86 
  shr XX,cl (XX -  ॣ),  ᤢ
 ᮤন ॣ XX  cl  ࠢ ( 筮
 ।⠢, ⢥.  ਬ, cl = 5, ax = 37 =
 100101b => ᫥ shr ax,cl ax = 1).  8086 ᤢ 
  cl ,  80186   -  cl mod 20h. ਬ, cl = 21h,
 ax = 0ffffh = 1111 1111 1111 1111b.  8086 ᫥ shr ax,cl 
 ax 㤥 0, 80186+ ᤢ   1   AX = 7fffh.

      , ᭠  push sp. 8086  80186 ᭠砫
  ᮤঠ sp, ⥬    ⥪.
  80286+   .  ࠧ, 
 १ 믮:
 push   sp
 pop    ax
   8086  80186 ax==sp-2,   80286+ ax==sp.

       㦥, ᫨  筮 ᭨,    
 286  ,  ᯮ짮 뢠 6.  ⮣ 㦭
  樨,    襣   
   襣.  । "ன"  ᯮ짮
  ,    32-ࠧ來묨 ॣࠬ. 
 "⢥ન"   xadd (== add + xchg), ன 
  "ன".  Pentium    ,  祣  ...
  ⭮,  ணࠬ  । 稥 
 Pentium .     ᯮ  ᢮ ணࠬ 
 । Pentium.   १ 믮
 ᫥⥫쭮:

 mov    cs:change_me,0
                db      0b9h    ; 0b9h -  mov cx,const
 change_me      dw      1

    80x86  cx 㤥 饭 1.  믮
 ⮩  ᫥⥫쭮  Pentium cx == 0.  ᫨ -
  ଠ   Pentium  ᮮ 
 (쬠 ࠢ   㡠,  " MrStrange").
  ,  ᫥ Pentium ⠪  
 .  㬠,   ⢨⥫쭮 ᫥  ⨬, ⠪ 
  䨧᪨ -⠪  P5 .

       ਢ  ணࠬ  㭪 cpu, 
  ॡ ࠬ஢  맮  頥:

 ax = 0   8086/8088
 ax = 1   80186
 ax = 2   80286
 eax = ax = 3  80386
 eax = ax = 4  i486
 eax = ax = 5  Pentium



.model  tiny
.code
        org 100h
        .8086
start:
        jmp     begin
cpu     proc    near
        push    cx dx bx es ds

        push    cs
        pop     ds

        mov     ax,0ffffh
        mov     cl,21h
        shr     ax,cl           ;  8086 ax == 0,  80186   - 7fffh
        xchg    ax,cx
        jcxz    this_is_8086
        push    sp
        pop     ax
        cmp     ax,sp           ;  286 ax == sp,    186
        jne     this_is_186
; ஢ਬ  Pentium
        mov     change_me,0
                db      0b9h    ; 0b9h -  mov cx,।⢥_祭
change_me       dw      1
        jcxz    this_is_pentium
; ᫨    ,   - 286, 386  486.
; ⠭ ࠡ稪 6- 뢠  ᥡ
        mov     ax,3506h
        int     21h
        push    es
        push    bx
        mov     ax,2506h
        mov     dx,offset myInt1
        int     21h
        mov     ax,2
.386
; 믮塞   386
        xor     eax,eax        ;   ᥡ 㫨 eax
        mov     ax,3
.486
        xadd    eax,edx        ;   ࠡ⠥ ⮫쪮  486  
        mov     eax,4          ; four eighty six
.8086
now_we_know_cpu:
        pop     dx
        pop     ds
        push    ax
        mov     ax,2506h
        int     21h             ; ⠭   6
        pop     ax
        jmp     exit_cpu
this_is_pentium:
.386
        mov     eax,5
.8086
        jmp     exit_cpu
this_is_186:
        mov     ax,1
        jmp     exit_cpu
this_is_8086:
        xor     ax,ax
exit_cpu:
        pop     ds es bx dx cx
        retn
cpu     endp

myInt1  proc
        pop     cx
        mov     cx,offset now_we_know_cpu
        push    cx
        iret    ; 㫨   now_we_know_cpu
myInt1  endp

;  ࠡ 㭪樨 cpu.   everything is
; clear, so I didn't insert any comment.
firstMessage    db      "Detect CPU type, Copyright (c) by MrStrange."
                db      " The show must go on!"
                db      13,10,10,"You've got ",'$'
_8086   db      "8086/8088",'$'
_186    db      "80186",'$'
_286    db      "80286",'$'
_386    db      "80386",'$'
_486    db      "i486",'$'
_pent   db      "Pentium",'$'
message dw      offset _8086, offset _186, offset _286, offset _386
        dw      offset _486,  offset _pent

begin:
        mov     ah,9
        mov     dx,offset firstMessage
        int     21h
        call    cpu
        shl     ax,1
        xchg    ax,si
        mov     dx,message[si]
        mov     ah,9
        int     21h
        int     20h
end     start


      ஢   2 室 (tasm filename /m2).

       ணࠬ  뢠  Pentium  80186. Handle
 with care.

        , ᫨  ⭠ -  
 Pentium, ன   i486,  ᠬ⥫쭮  ᪮쪮
 㪮 㭪 cpu,  ᯮ P5  
 奬 ->   ஬ ,  ᫥ 祪:

 xadd   eax,edx
 mov    eax,4

 :

 Any_Unique_P5_command
 mov    eax,5

      ᫥     inc ax, ᫨, 筮,
 Any_Unique_P5_command   ᮤন eax.

      ⢥, ᫨ 室    ⨯
 ,   ଠ ⨯:  80x86 or higher,
 뫮  譨   ᢮ ணࠬ  楤 cpu (
   100 ). ᫨ 㦭 ஢ ஢
   186    ணࠬ  ⠢
 ᫥騥 ப:

 mov    ax,0ffffh
 mov    cl,21h
 shr    ax,cl
 or     ax,ax
 jz     error_this_is_8086
 this_is_80186_or_higher:
 ; ...

    11 

       ஢ન  80286 ⠢  ணࠬ:

 push   sp
 pop    ax
 cmp    ax,sp
 jne    error_this_is_80186_or_lower
 this_is_80286_or_higher:
 ;...

    6 

       ஢ન  稥  386  襣 
 ᯮ짮  ᮡ ॣ 䫠.  ⭮,
 ॣ 䫠 ஢ 8086  80186  ᫥騥
 :

   15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
  Ŀ
  XXXXXXXXOFDFIFTFSFZFXXAFXXPFXXCF
  

      ﭨ ⮢ 12-15  ।.   
 pushf   ⥪   ⮢ 12-15  (..
 ᫥ 믮: pushf pop ax, 訥   ax 
 栬, ax == 1111 ???? ???? ????b).   80286 
  ଠ ॣ flags ⠪:


    15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
   Ŀ
   00NTIO PLOFDFIFTFSFZF00AF00PF01CF
   

   NT    nested task                  -  
   IO PL input/output privelege level - ஢ ਢ /

       12-14    ᫠  ॠ쭮 ०
 ࠡ .  80286    
 .  ᥣ 襭  0.   80386+ 䫠 12-14
 ⠭  ᮮ⢥⢨  ⥬ 祭ﬨ,  뫨 㤠
 ᥭ ᫥.  ﭨ  䫠    
 ࠡ   R-०.  ࠧ,  ।
  80386+ 筮 ⠢  ᢮ ணࠬ ⠪
 ப:

 mov    ax,1000h
 push   ax
 popf
 pushf
 pop    ax
 and    ax,0f000h
 cmp    ax,01000h
 jne    error_this_is_80286_or_lower
 this_is_80386_or_higher:
 ;...

    15 

       ஢ન  Pentium ᯮ㥬 :

 mov    cs:change_me,0
 db     0b9h    ; 0b9h -  mov cx,।⢥_祭
 change_me      dw      1
 jcxz   this_is_pentium
 error_this_is_not_pentium:
 ;....

    12 .

        ,  ஢ 稥  i486 
 ᯮ짮 뢠 6.  "⢥ઠ" ⠪  ⫨砥
  "ன",  - -  ᯥ樠쭮
 㡥  稨 486+.