flat assembler
Message board for the users of flat assembler.
Index
> Main > CPUID (not really) 80286 | Tomasz's code |
| Author |
|
|
DOS386 18 Jun 2007, 05:54
Tomasz wrote ( MODES.INC ) :
Code: mov ax,7202h push ax popf pushf ; Unpredictable effect ??? pop bx cmp ax,bx je processor_ok ; >=80386 The code should find out whether CPU is 80386 or newer or below. But I suspect that it can't work. http://www.online.ee/~andre/i80386/Opcodes/PUSHF-PUSHFD.html There is MUCH of such "CPUID" code around, most of it is a PUSHF/POPEF based mess (Tomasz's is the simplest one), most of them assume to work (or must work since in ordinary PM (80486 test only)). I found some code that addresses the problem and tries to workaround it (in a very complicated way, and looks buggy to me, not enough hardware to test). Is it correct that this code will return junk when running in "V86" Found also (should find out whether 80286 or newer or below): Code: mov ax,sp push sp ; 86/186 will push sp-2 pop cx ; others will push sp cmp ax,cx je cpu_286 ; if >=80286 Commenting is confusing, does "others" include 8088,80188 and NEC ? Or is this code good and safe ? By safe I mean that it will always return "80286=false" on ALL older CPU's lacking the SMSW instruction (8086, 8088, 80186, 80188, NEC Vxxx, ... , and always return "80286=true" on 80286 and newer CPU's, even when in V86 mode. Are there other possibilities (banned instructions / methods: PUSHF/POPEF, any interrupts, try-and-fail to brew an illegal instruction exception, CLI/STI) ? _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
|
|
f0dder 18 Jun 2007, 11:33
Imho, why even bother with 386 detection these days? People that still run hardware that old will very likely know what they're doing.
|
|||
|
|
DOS386 19 Jun 2007, 00:16
> I use this code to check if processor can execute CPUID
YES. But this was about testing 80286 against older models > The Intel doc's are quite clear about this: > 32-bit processors in real-address mode—bit 15 (reserved) is always cleared YES. They are very clear. Works only in real mode _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
|
|
kohlrak 19 Jun 2007, 01:44
f0dder wrote: Imho, why even bother with 386 detection these days? People that still run hardware that old will very likely know what they're doing. Either that or they're poor. |
|||
|
|
Tomasz Grysztar 22 Jun 2007, 07:52
DOS386 wrote: Is it correct that this code will return junk when running in "V86" I had it tested in V86 on various machines and it was always working correctly. Note that this code has to check only whether the machine supports 32 bits, nothing more. |
|||
|
|
Tomasz Grysztar 22 Jun 2007, 07:55
DOS386 wrote: YES. They are very clear. Works only in real mode V86 mimics the real mode as much as possible. |
|||
|
|
DOS386 22 Jun 2007, 23:53
Thanks ... but you possibly did not understand the goal of my post
> I had it tested in V86 on various machines and it was always working correctly. Not really surprising. > Note that this code has to check only whether the machine supports 32 bits, nothing more. Sure. I know. > V86 mimics the real mode as much as possible. as much as or much less - obviously, it seems to work, it just happens that the PUSHF finally (after a excessive delay ?) pushes something that then evaluates to "YES we have 32-bit" - nevertheless, it is not really obligated to do - it causes a "secret" GPF and one can just hope that it will end up in correct pushing ... Is the PUSH SP - code better / good ? I am aware that it should test for 80286 only and is not a drop-in replacement of your 80386 test. |
|||
|
|
rugxulo 25 Jun 2007, 01:49
DOS386, use the above for real mode but this for pmode:
http://www.ctyme.com/intr/rb-4621.htm http://www.delorie.com/djgpp/doc/dpmi/api/2f1687.html In short, call int 2Fh,1687h; if that's successful (AX=0) and "TEST BX,1" is NZ (non-zero, i.e. 32-bit programs supported), and CL >= 3 (386), then you're probably on a 32-bit, Intel-compatible chip. |
|||
|
|
DOS386 28 Jun 2007, 01:03
Quote: In short, call int 2Fh,1687h Thanks, but I know this call and does does not really do what I need It can provide a suspect of 80286 or 80386, but NOT the evidence of 808x or 8018x |
|||
|
|
rugxulo 28 Jun 2007, 07:06
I forwarded you an e-mail the other day (or so I thought) about detecting such. Did you not get it? (I'm confused.)
EDIT: Okay, read this: Quote:
|
|||
|
|
rugxulo 13 Jul 2007, 00:17
And there's also this (old, pre-Pentium Pro) file:
http://www.programmersheaven.com/download/15803/download.aspx CPU115.ZIP wrote:
|
|||
|
|
DOS386 27 Aug 2007, 21:45
The solution seems to exist and be simple, unfortunately nobody pointed me to it
http://board.flatassembler.net/topic.php?t=7565 FASM 1.0 used to test the correct way (but failed to jump then ???) ... maybe I have correct code now ... but still no 16-bit CPU to test Tomasz wrote: > V86 mimics the real mode as much as possible. Intel wrote (80386 manual): > CLTS appears in operating system software, not in application programs. > It is a privileged instruction that can only be executed at privilege level 0. > Flags Affected > TS = 0 (TS is in CR0, not the flag register) > Protected Mode Exceptions > #GP(0) if CLTS is executed with a current privilege level other than 0 > Real Address Mode Exceptions > None (valid in Real Address Mode to allow initialization for Protected Mode) > Virtual 8086 Mode Exceptions > Same exceptions as in Real Address Mode Either the manual is bugged or I'm stupid |
|||
|
|
rugxulo 29 Aug 2007, 00:40
DOS386 wrote:
Tomasz didn't have ONLY8086.INC at that time. DOS386 wrote:
Try on Joris' Retro 8086 simulator (better than nothing ... or nag Jim Leonard to test it on his 8088). |
|||
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.