summaryrefslogtreecommitdiff
path: root/v4.0/src/INC/CPUTYPE.INC
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/INC/CPUTYPE.INC')
-rw-r--r--v4.0/src/INC/CPUTYPE.INC39
1 files changed, 39 insertions, 0 deletions
diff --git a/v4.0/src/INC/CPUTYPE.INC b/v4.0/src/INC/CPUTYPE.INC
new file mode 100644
index 0000000..da6f102
--- /dev/null
+++ b/v4.0/src/INC/CPUTYPE.INC
@@ -0,0 +1,39 @@
1; Note: this must be a macro, and not a subroutine in the BIOS since
2; it is called from both CODE and SYSINITSEG.
3;
4;------GET_CPU_TYPE------------------------------------------------------------May, 88 by MW
5; Returns: AX = 0 if 8086 or 8088
6; = 1 if 80286
7; = 2 if 80386
8;
9Get_CPU_Type macro
10 pushf
11 push bx ; preserve bx
12 xor bx, bx ; init bx to zero
13
14 xor ax,ax ; 0000 into AX
15 push ax ; put it on the stack...
16 popf ; ...then shove it into the flags
17 pushf ; get it back out of the flags...
18 pop ax ; ...and into ax
19 and ax,0F000h ; mask off high four bits
20 cmp ax,0F000h ; was it all 1's?
21 je cpu_8086 ; aye; it's an 8086 or 8088
22
23 mov ax,0F000h ; now try to set the high four bits..
24 push ax
25 popf
26 pushf
27 pop ax ; ...and see what happens
28 and ax,0F000h ; any high bits set ?
29 jz cpu_286 ; nay; it's an 80286
30
31cpu_386: ; bx starts as zero
32 inc bx ; inc twice if 386
33cpu_286: ; just inc once if 286
34 inc bx
35cpu_8086: ; don't inc at all if 086
36 mov ax, bx ; put CPU type value in ax
37 pop bx ; restore original bx
38 popf
39 endm