Path: utzoo!utgpu!water!watmath!clyde!att!pacbell!ames!pasteur!ucbvax!decwrl!labrea!polya!rokicki From: rokicki@polya.STANFORD.EDU (Tomas G. Rokicki) Newsgroups: comp.sys.amiga.tech Subject: Re: Another question on the 80286- er, 68000 memory models Message-ID: <2869@polya.STANFORD.EDU> Date: 20 May 88 18:13:56 GMT References: <8805182223.AA20918@cory.Berkeley.EDU> <2653@louie.udel.EDU> Reply-To: rokicki@polya.Stanford.EDU (Tomas G. Rokicki) Organization: Stanford University Lines: 62 > No, i have no problem with your discussion. I knew all that > stuff anyway. But the fun i am having with xenix kernel hacking > has me a little worried, even though i have not been burned yet ... > For example, i put a pointer into a structure. Now if i am > in the small data mode, then maybe what gets put in is 16 bits. > Then i go to the library which is large model, ... bang! > Anyway, i will try to work up a more concrete example and see > if this scenario is possible. I sure hope not.And i have not > seen it yet, or been burned by it, but it bothers me somehow. Let's get this all straight. There are three independent things that affect the `model' on the Lattice and Manx compilers: * data addressing. This can either be 32-bit absolute or 16-bit relative. *Pointers are 32-bits in either case*. In the latter case, you are only allowed 65K of data. You can mix these two models, so long as any data used by the 16-bit relative stuff is within the first 65K of the data segment (right?) You should always use 16-bit relative, and if your code has more than 65K of static data, malloc it anyway. Please. It's real simple to do. Another problem is in interrupt code, where you need to set up the base register with a call to _geta4() in Manx, and something similar in Lattice (I've forgotten what it is) at the very beginning. * code addressing (jsr's.) These can either be 32-bit absolute or 16-bit relative. Again, you can mix models. If using 16-bit relative, then you have a small problem with branches that are farther than +/- 32K. Manx solves this by indirecting off an automatically created vector list in the data portion of the program. Lattice does something similar (but I seem to be having troubles with it somehow . . .) Always use 16-bit relative; no sense not to, since the long ones are taken care of automatically, and smaller code size is usually good. Again, in interrupt code, you need to set up a4 to get access to these fake long branches in 16-bit offset mode. * int size. Both Manx and Lattice allow 16 and 32-bit ints. Again, you can mix models, but be *very* careful when you do so, and pull in the correct libraries, due to the way args are passed on the stack and the way printf/scanf work. You should use one or the other and stick with it. In summary? The only thing that really matters is int size, and that you use the correct libraries for the int size you are working with. The other models should mix freely, assuming you don't have more than 65K of statically allocated data that pushes the compiler's data out of range. Someone please correct me where I'm wrong. -tom -- /-- Tomas Rokicki /// Box 2081 Stanford, CA 94309 / o Radical Eye Software /// (415) 326-5312 \ / | . . . or I \\\/// Gig 'em, Aggies! (TAMU EE '85) V | won't get dressed \XX/ Bay area Amiga Developer's GroupE