steve@wlbr.UUCP (Steve Childress) (09/06/85)
... ... Relative to the Microsoft C compiler ( != Lattice) ... When using the large (data space) model, I understand that MS just ignores the problem of pointers in the 808x CPUs, ie, MS just compares the low 16 bits, as I understand. To detect a pointer operation which yields a value in excess of 2^16, the burden falls upon the programmer (!). Lattice C, despite the lousy library, does handle 20 bit pointers, though with speed penalties arising from normalization. How is one to write C code to handle: char *p, x[200000] p++ = &x[65535]; Where am I wrong here? Did Microsoft REALLY throw us a curve? Regards, Steve Childress Eaton IMS R&D Group MS 43 31717 La Tienda Drive Westlake Village, CA 91360 (818) 889-2211 X2148 {trwrb, scgvaxd, ihnp4, voder, vortex} !wlbr!steve or ...wlbr!wlbreng1!steve
caf@omen.UUCP (Chuck Forsberg WA7KGX) (09/08/85)
In article <346@wlbr.UUCP> steve@wlbr.UUCP (Steve Childress) writes: >Relative to the Microsoft C compiler ( != Lattice) ... > >When using the large (data space) model, I understand that MS just >ignores the problem of pointers in the 808x CPUs, ie, > >MS just compares the low 16 bits, as I understand. To detect a pointer >operation which yields a value in excess of 2^16, the burden falls upon >the programmer (!). > >Lattice C, despite the lousy library, does handle 20 bit pointers, though with >speed penalties arising from normalization. > > >How is one to write C code to handle: > char *p, x[200000] > p++ = &x[65535]; > >Where am I wrong here? Did Microsoft REALLY throw us a curve? > It's a question of memory models. Microsoft's LARGE model corresponds to Lattice's large model with the -s option, which gives tighter code by not bothering with the segment registers. What you want is the Microsoft HUGE model (aptly named). It's still rather buggy, but it is possible to get some simple programs to work with it by rewriting the code to eliminate non trivial expressions. To put the code quality issue into perspective, here are some results of 32 bit compilations of siev.c, the "Byte" benchmark with register declarations: Compile - Link Execute Real User Real User Bytes System 27 6.6 1.1 1.0 140 Charles Rivers + Unos % 22 1.8 2.0 1.2 144 Parallel 68k + Zenix # 9 2.4 2.3 2.3 140 SUN 68010 4.2 BSD 6/84 8.1 1.8 2.6 2.2 104 4.2 BSD VAX 11/780 17.5 5.0 5.8 5.7 267 9mHz PC-AT Zenix + huge model 5/85 50 - 30 - 252 IBMPC DOS 2.1 Lattice 2.00 8/84 + Note that the 9mHz PC-AT is many times faster than a PC. Perhaps someday the Cmerge HUGE model will be good enough to compile (and correctly execute!) rn, compress, and other programs that cry out for more memory space. This might even happen before all 16 bit Intel chips have been replaced by 80386 types. -- Chuck Forsberg WA7KGX ...!tektronix!reed!omen!caf CIS:70715,131 Omen Technology Inc 17505-V NW Sauvie Island Road Portland OR 97231 Home of Professional-YAM, the most powerful COMM program for the IBM PC Voice: 503-621-3406 Modem: 503-621-3746 (Hit CR's for speed detect) omen Any ACU 1200 1-503-621-3746 se:--se: link ord: Giznoid in:--in: uucp
alan@drivax.UUCP (Alan Fargusson) (09/10/85)
> char *p, x[200000] ^^^^^^ > p++ = &x[65535]; > > Where am I wrong here? Did Microsoft REALLY throw us a curve? No, iNTEL did. You can't do this even in large model. Even in large model a single element must be less than 64K bytes. This is partly because the index register is 16 bits. When you think *86 think 16 bits. Thats what all the registers are. No larger. -- Alan Fargusson. { ihnp4, amdahl, mot }!drivax!alan
connery@bnrmtv.UUCP (Glenn Connery) (09/10/85)
> > char *p, x[200000] > ^^^^^^ > > p++ = &x[65535]; > > > > Where am I wrong here? Did Microsoft REALLY throw us a curve? Can't you just use the HUGE modifier on the pointer to get this to work? If not then I'm not sure what its for... ...Glenn *** REPLACE THIS LINE WITH YOUR MESSAGE ***
bc@cyb-eng.UUCP (Bill Crews) (09/13/85)
> > char *p, x[200000] > ^^^^^^ > > p++ = &x[65535]; > > > > Where am I wrong here? Did Microsoft REALLY throw us a curve? > > No, iNTEL did. You can't do this even in large model. Even in large model > a single element must be less than 64K bytes. This is partly because the > index register is 16 bits. When you think *86 think 16 bits. Thats what > all the registers are. No larger. > > Alan Fargusson. In LATTICE's large model, this is valid code, unless one chooses to economize by using the -s option, which generates *much* tighter code, but which is nevertheless limited as in the Microsoft compiler. -- / \ Bill Crews ( bc ) Cyb Systems, Inc \__/ Austin, Texas [ gatech | ihnp4 | nbires | seismo | ucbvax ] ! ut-sally ! cyb-eng ! bc