8086 (was Re: more talking to the press.)

From: Hans Franke <Hans.Franke_at_mch20.sbs.de>
Date: Mon Nov 17 13:43:13 2003

Am 16 Nov 2003 2:36 meinte Fred N. van Kempen:

> On Sat, 15 Nov 2003, Fred Cisin wrote:
>
> > Wasn't presence/absence of that bug one of the tests for presence of the
> > NEC V30 v intel 8086?
> Yes, we had this in Minix to test for V30/X86. Cant member what
> the V20/X88 was, probably a missing opcode.

Aua. This hurts.

There where several tests to distinguish the CPUs. Personaly I
only used two of them in real products, but at one time I played
around to produce a test as good as possible. Intel usualy documented
the tests using the flag register, especialy for the later CPUs. it
can prety much distinguisch getween 8086,286 and 386. To see if I
have a 286, I set and the clear bit 12 to 15 - was 15 able to be set,
it's a 286, while if I could set 12-14, but not 15, it's a 386. The
other was to find if I had a 186 compatible instruction set (pusha,
popa, bound, enter, leave, etc. oh, yes, and ins/outs, my favorites),
which is true for everything except 8086/88 (even V20/30), which eas
rather easy: Shift left for 32 Bits, and nothing if happens it's 186
compatible, otherwise it's a 8088/86. The other, less popular (since
not recommended by Intel) technique was to code a pusha, which true
8088/86 interpreted as a Jump *+2 (or just ignoring the next two bytes),
so one could now code here something like CLC, or check the stackpointers
(don't forget the NOP). The last trick I re,member was the POP CS,
which worked on a 8086/88, while generated an invalid opcode int on
186 and above.

Now, to see if it's a V20/30 or not, one just goes ahead, sets the
zero flag and does a multiplication (non zero result) - if Zero is
still set, it's a V20 :) Another trick, at the same corner was the
behaviour of AAD, which on intel realy uses the second byte as operand
for the multiplication, while on V20/30, independent form the coding
always 10 (0Ah) was used.

To get the bus size, two methods are possible, either do self modifying
code, and detect the legth of the prefetch que - the 8 Bit types
(8088/188/V20) had 4 bytes, refilled when at least one Byte is empty,
while the 16 Bit types had 6 Bytes and would be refiled only if two
or more positions where empty. The other, less destructive was just
to time a lodsw loop - if you had a sufficient good timer base, just
go ahead and load huge data amounts into A (REP LODSW) and see what
took you longer.

But usualy it made no sense, since it didn't effect the operations you had at hand.

Gruss
H.
--
VCF Europa 5.0 am 01./02. Mai 2004 in Muenchen
http://www.vcfe.org/
Received on Mon Nov 17 2003 - 13:43:13 GMT

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:36:19 BST