source: trunk/src/opengl/glide/sst1/glide/cpudtect.asm

Last change on this file was 2885, checked in by sandervl, 26 years ago

Created new Voodoo 1 Glide dir

File size: 5.0 KB
Line 
1;;
2;; THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
3;; PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
4;; TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
5;; INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE
6;; DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com).
7;; THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
8;; EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
9;; FULL TEXT OF THE NON-WARRANTY PROVISIONS.
10;;
11;; USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
12;; RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
13;; TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
14;; AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
15;; SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
16;; THE UNITED STATES.
17;;
18;; COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
19;;
20;; $Header: /home/ktk/tmp/odin/2007/netlabs.cvs/odin32/src/opengl/glide/sst1/glide/cpudtect.asm,v 1.1 2000-02-25 00:31:09 sandervl Exp $
21;; $Log: cpudtect.asm,v $
22;; Revision 1.1 2000-02-25 00:31:09 sandervl
23;; Created new Voodoo 1 Glide dir
24;;
25;
26; 2 3/04/97 9:10p Dow
27; Neutered mutiplatform multiheaded monster.
28;;
29;;
30
31TITLE cpudtect.asm
32
33.586P
34
35CODE32 segment para use32 public 'CODE'
36CODE32 ends
37DATA32 segment para use32 public 'DATA'
38DATA32 ends
39BSS32 segment para use32 public 'BSS'
40BSS32 ends
41DGROUP group BSS32, DATA32
42 assume cs:FLAT, ds:FLAT, ss:FLAT, es:FLAT
43
44;;; Some useful constants
45; CPU Type
46CPUTypeUnknown = 0ffffffffh
47CPUTypePrePent = 4h
48CPUTypeP5 = 5h
49CPUTypeP6 = 6h
50
51;;; References to external data:
52
53CODE32 SEGMENT
54;;
55;; cpu_detect_asm - detect the type of CPU
56;;
57;; USAGE:
58;;
59;; int _System cpu_detect_asm(void);
60;;
61;; returns 4 for non-pen
62
63PUBLIC _cpu_detect_asm
64_cpu_detect_asm PROC
65 pushad ; save all regs.
66
67 ; First, determine whether CPUID instruction is available.
68 ; If it's not, then it's a 386 or 486.
69 pushfd ; push original EFLAGS.
70 pop eax ; pop into eax
71 mov ecx, eax ; save original EFLAGS in ecx
72 xor eax, 0200000h ; flip ID bit in EFLAGS
73 push eax ; put it back on stack
74 popfd ; pop into EFLAGS
75 pushfd ; get EFLAGS back
76 pop eax ; into eax
77 xor eax, ecx ; check to see if we could toggle ID
78 jz NotPentium ; Sorry, not P5 or P6.
79
80 ;
81 ; Now determine whether it's an intel P6 CPU.
82 ;
83 ;; Is it an Intel CPU?
84 xor eax, eax ; eax = 0.
85 cpuid ; get cpuid
86 xor ebx, 0756e6547h ; "Genu"
87 jnz NotIntel
88 xor edx, 049656e69h ; "ineI"
89 jnz NotIntel
90 xor ecx, 06c65746eh ; "ntel"
91 jnz NotIntel ;
92 ;; Verifying architecture family
93 mov eax, 1
94 cpuid ; get family/model/stepping
95 shr eax, 8 ; rid of model & stepping number
96 and eax, 0fh ; use only family
97 cmp eax, 6
98 jl IsP5 ; It's a P5
99 ;; Else it's a P6
100 ;
101 ; Intel P6 processor.
102 ; Make sure it supports Memory Type Range Request registers
103 ;
104IsP6:
105 popad
106 mov eax, 6 ;
107 ret ; return
108
109IsP5:
110 popad
111 mov eax, 5 ;
112 ret
113
114NotPentium:
115 popad
116 mov eax, 4
117 ret
118
119NotIntel:
120 popad
121 mov eax, 0ffffffffh
122 ret
123
124_cpu_detect_asm ENDP
125
126
127;------------------------------------------------------------------------------
128; this routine sets the precision to single
129; which effects all adds, mults, and divs
130 align 4 ;
131 PUBLIC _single_precision_asm
132_single_precision_asm PROC
133 push eax ; make room
134 fnclex ; clear pending exceptions
135 fstcw WORD PTR [esp]
136 mov eax, DWORD PTR [esp]
137 and eax, 0000fcffh ; clear bits 9:8
138 mov DWORD PTR [esp], eax
139 fldcw WORD PTR [esp]
140 pop eax
141 ret 0
142_single_precision_asm ENDP
143
144;------------------------------------------------------------------------------
145; this routine sets the precision to double
146; which effects all adds, mults, and divs
147 align 4 ;
148 PUBLIC _double_precision_asm
149_double_precision_asm PROC
150 push eax ; make room
151 fnclex ; clear pending exceptions
152 fstcw WORD PTR [esp]
153 mov eax, DWORD PTR [esp]
154 and eax, 0000fcffh ; clear bits 9:8
155 or eax, 000002ffh ; set 9:8 to 10
156 mov DWORD PTR [esp], eax
157 fldcw WORD PTR [esp]
158 pop eax
159 ret 0
160_double_precision_asm ENDP
161
162CODE32 ENDS
163END
Note: See TracBrowser for help on using the repository browser.