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

git-svn-id: trunk@25034 -
This commit is contained in:
nickysn 2013-07-03 15:43:01 +00:00
parent 1c84c3edbf
commit 3505ba4ee6
2 changed files with 34 additions and 2 deletions

View File

@ -567,8 +567,8 @@ const
{$endif cpui386}
{$ifdef cpui8086}
{ 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. }
Test8087 : byte = 3;
{ will be detected at startup }

View File

@ -19,6 +19,7 @@
extern PASCALMAIN
extern dos_psp
extern dos_version
extern __Test8086
extern _edata ; defined by WLINK, indicates start of BSS
extern _end ; defined by WLINK, indicates end of BSS
@ -68,6 +69,37 @@ no_bss:
xchg al, ah
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
; TODO: also support user specified heap size
; try to resize our main DOS memory block until the end of the data segment