From: Stanislav Kolar <KOLAR@JONAS.ZCU.CZ>
Subject: Detekce typu procesoru
Date: Tue, 21 Mar 1995 09:40:44 METDST
Next Article (by Date): Re: VC kontra NC Vit Rocek
Previous Article (by Date): Re: AVG update ??? Petr Adamec
Articles sorted by: [Date]
[Subject]
> Date sent: 21 Dec 94 9:19:00 MET > From: David Havlin <asm.42%echo@a1fel.feld.cvut.cz> Ahoj. Posilam ti neco z asm.42. Snad ti to pomuze. > Tady mas fragment meho zdrojaku, kdyz tak zavolej/napis pokud ti bude neco > nejasne. > > .486P ; Nyni je treba prepnout na > ; instrukcni sadu I80486 (protected) > testI386orI486: ; Test typu I80486,SX ci I80386,SX > enter 0000h, 00h ; uchopeni > mov edx, esp ; STACKu > and esp, -4 ; zaokrouhlit DOLU na delitelnost 4 > ; aby po nastaveni AC nedoslo k int > 17h > pushfd ; ulozeni 32bitovych FLAGu > pop eax ; do EAX > mov ecx, eax ; uchovani FLAGu v ECX > xor eax, 00040000h ; nastaveni 18. bitu 'FLAGu' na 1 > (AC) > push eax ; puvodni hodnota FLAGu s > nastavenym > popfd ; 18. bitem se ulozi do > FLAGu > pushfd ; a pak zpatky > pop eax ; do registru EAX > xor eax, ecx ; priznak zmeny 18. bitu (1=ano) > shr eax, 18d ; posun 18. bitu do bitu 0 > and eax, 0001h ; nulovani ostanich bitu > push ecx ; z ECX se obnovi > popfd ; FLAGy > mov esp, edx ; uvolneni > leave ; STACKu > dec ax ; decrementace AX (tj. 0-15 bit EAX) > jne testI386orI386SX ; AX bylo 0 -> 386,386SX > int 11h ; Get EQUIPMENT list > and ax, 2 ; test zda je koprocesor > jz I486SX ; ne -> > mov ax, CPU_INTEL_80486 ; > jmp testI586 ; = I80486 nebo I80486SX s koproc. > I486SX: > mov ax, CPU_INTEL_80486SX ; = I80486SX bez koprocesoru > > testI586: ; Test typu 80586 (Pentium) > push ax ; > pushfd ; test zda jde nastavit BIT 21 > pop eax ; v EFLAGS na 1 ci ne je stale 0. > mov ecx, eax ; Na 486 je stale 0, Pentium ho > pouziva > or eax, 00200000h ; - CPU ID flag > push eax > popfd > pushfd > pop eax > test eax, 00200000h > je no586 ; neni 586 -> test Cyrix 486 > mov eax, 00000001h ; CPUID - get CPU info > db 0Fh, 0A2h ; CPUID instruction > and ah, 0Fh ; vymaskovani model info > mov dx, CPU_INTEL_80386 ; default = 80386 > cmp ah, 04h ; test zda nejde o NEW i486 > jb end586 ; new 386DX > mov dx, CPU_INTEL_80486 ; = I80486 > je end586 ; new 486DX > mov dx, CPU_INTEL_80586 ; = I80586 > end586: > push ecx > popfd > pop ax > mov ax, dx > jmp konec > no586: ; jedna se o 486, nasleduje test > push ecx ; zda nejde o Cyrix > popfd > pop ax > > testCyrixCpu: ; Test zda CPU 486 neni Cyrix > push ax ; (mozna lze takto testovat > mov cx, 08D5h ; i zda se nejedna o Cyrix 586?) > xor ax, ax > mov dx, ax > cmp ax, ax > pushf > mov ax, 0FFFFh > mov bx, 0004h > div bx > pushf > pop ax > pop bx > pop dx > and ax, cx > and bx, cx > cmp ax, bx > jne endCyrix > mov dx, CPU_CYRIX_80486 > endCyrix: > mov ax, dx > jmp konec > > testI386orI386SX: ; Test typu I80386/I80386SX > xor ax, ax ; Nastaveni AX na 0 aby se pri > cmp skip, TRUE ; pripadnem preskoceni testu 386SX od > je skipTestI386orI386SX ; 386DX vratil jako CPU 386DX > ; Provede se test zda neni V86 rezim > pushfd ; ulozeni 32bitovych FLAGu > pop ebx ; do EBX > shr ebx, 17d ; posun 17. bitu do bitu 0 (VM) > and ebx, 0001h ; nulovani ostanich bitu > dec bx ; decrementace BX (tj. 0-15 bit EBX) > jz skipTestI386orI386SX ; Procesor je v rezimu V86 (obskok) > enter 0000h, 00h ; uchopeni STACKu > mov ebx, cr0 ; - ulozeni CR0 do EBX > mov eax, cr0 ; nastaveni > and eax, -17 ; 4. bitu > mov cr0, eax ; registru CR0 na 0 (ET) > mov eax, cr0 ; ulozeni > shr eax, 04h ; 4. bitu registru CR0 > and eax, 0001h ; do bitu 0 registru EAX > mov cr0, ebx ; obnova CR0 z EBX > leave ; uvolneni STACKu > skipTestI386orI386SX: > dec ax ; decrementace AX (tj. 0-15 bit EAX) > mov ax, CPU_INTEL_80386 ; AX bylo 0 -> I80386 > jne konec ; = I80386 > mov ax, CPU_INTEL_80386SX ; = I80386SX > > .8086 ; Prepnuti zpet na instrukcni > ; sadu I8086 > konec: > > > > David (02-7913483) > Bye Standa K.
Next Article (by Date): Re: VC kontra NC Vit Rocek
Previous Article (by Date): Re: AVG update ??? Petr Adamec
Articles sorted by: [Date]
[Subject]