Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp
Path: utzoo!watmath!clyde!cbosgd!ihnp4!zehntel!dual!amdcad!decwrl!sun!gnu
From: gnu@sun.uucp (John Gilmore)
Newsgroups: net.micro.pc
Subject: Re: 80286 microprocessor problems
Message-ID: <1838@sun.uucp>
Date: Tue, 4-Dec-84 01:47:19 EST
Article-I.D.: sun.1838
Posted: Tue Dec  4 01:47:19 1984
Date-Received: Wed, 5-Dec-84 01:02:14 EST
References: <457@intelca.UUCP>
Organization: Sun Microsystems, Inc.
Lines: 48

> intelca!wizard sez:
> 	Here we go again with more astounding ignorance.
> I suggest that you reread the 80286 programmers reference manual
> The 80286 was not intended as a processor for simple minds...

I'll just leave that one alone.

> as some other so called 32 bit architectures. The protection mechanism
> works very well when used properly and provides the control that is
> needed by application and system programmers. 

I believe the original author wanted to write programs that dealt with
more than 64K of data.  That is, he didn't want to be protected, he
wanted to get at his data.  Given that, the question is:  how can a
compiler generate code to subscript a (say) 128Kbyte array, such as a
bitmap of a 1024x1024 screen, without somehow knowing how the operating
system is going to allocate segment descriptors?  On the 8086, it was
easy:  You take the address you want to get to, shift it down 4 bits,
and load that into a segment register.  Then use the low 4 bits to get
at the element you want within that segment.  On the 286, though, when
you load that segment register, it goes indirect thru a descriptor
which is NOT under the compiler's control.

Please believe that some of us understand how segment descriptors work,
and even understand the magic process that wastes a dozen cycles every
time you load one doing a subscript in the inner loop.  Can you just
give us a short listing of what assembler code should be generated to
subscript an array FOO of 128K bytes with index I, that is:

	static char foo[128*1024], c;
	long i;

	c = foo[i];

Please then show us the code to generate if 'static' is replaced by
'auto', that is, the array (say, a Z-buffer) is on the stack.

> 	3) As far as the ENTER and LEAVE instructions go. These
> 	instructions when used properly facilitate writing compact
> 	and very fast code most notably "C" code. 

The original question was how to use them with a stack bigger than
64K.  ("The display pointers are *only 16 bits*...").  I think stacks
bigger than 64K don't work on the 286 anyway, so there's no problem, by
definition.
--

The opinions expressed here are not those of Intel.