Browse Source

+ added CPU detection code in the msdos rtl startup in order to properly initialize the Test8086 variable

git-svn-id: trunk@25034 -
nickysn 12 years ago
parent
commit
3505ba4ee6
2 changed files with 34 additions and 2 deletions
  1. 2 2
      rtl/inc/systemh.inc
  2. 32 0
      rtl/msdos/prt0stm.asm

+ 2 - 2
rtl/inc/systemh.inc

@@ -567,8 +567,8 @@ const
 {$endif cpui386}
 {$endif cpui386}
 {$ifdef cpui8086}
 {$ifdef cpui8086}
   { will be detected at startup }
   { will be detected at startup }
-  { 0=8086, 1=80286, 2=80386 }
-  Test8086 : byte = 0;
+  { 0=8086/8088/80186/80188/NEC V20/NEC V30, 1=80286, 2=80386 or newer }
+  Test8086 : byte = 0; public name '__Test8086';
   { Always 387 or newer. Emulated if needed. }
   { Always 387 or newer. Emulated if needed. }
   Test8087 : byte = 3;
   Test8087 : byte = 3;
   { will be detected at startup }
   { will be detected at startup }

+ 32 - 0
rtl/msdos/prt0stm.asm

@@ -19,6 +19,7 @@
         extern PASCALMAIN
         extern PASCALMAIN
         extern dos_psp
         extern dos_psp
         extern dos_version
         extern dos_version
+        extern __Test8086
 
 
         extern _edata  ; defined by WLINK, indicates start of BSS
         extern _edata  ; defined by WLINK, indicates start of BSS
         extern _end    ; defined by WLINK, indicates end of BSS
         extern _end    ; defined by WLINK, indicates end of BSS
@@ -68,6 +69,37 @@ no_bss:
         xchg al, ah
         xchg al, ah
         mov word [dos_version], ax
         mov word [dos_version], ax
 
 
+        ; detect CPU
+        xor bx, bx  ; 0=8086/8088/80186/80188/NEC V20/NEC V30
+        ; on pre-286 processors, bits 12..15 of the FLAGS registers are always set
+        pushf
+        pop ax
+        and ah, 0fh
+        push ax
+        popf
+        pushf
+        pop ax
+        and ah, 0f0h
+        cmp ah, 0f0h
+        je cpu_detect_done
+        ; at this point we have a 286 or higher
+        inc bx
+        ; on a true 286 in real mode, bits 12..15 are always clear
+        pushf
+        pop ax
+        or ah, 0f0h
+        push ax
+        popf
+        pushf
+        pop ax
+        and ah, 0f0h
+        jz cpu_detect_done
+        ; we have a 386+
+        inc bx
+
+cpu_detect_done:
+        mov [__Test8086], bl
+
         ; allocate max heap
         ; allocate max heap
         ; TODO: also support user specified heap size
         ; TODO: also support user specified heap size
         ; try to resize our main DOS memory block until the end of the data segment
         ; try to resize our main DOS memory block until the end of the data segment