Message-Id: <199703191130.MAA07462@math.amu.edu.pl> Comments: Authenticated sender is From: "Mark Habersack" Organization: PPP (Pesticide Powered Pumpkins) To: "Alex" Date: Wed, 19 Mar 1997 12:28:57 +0100 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: Memory Models Reply-to: grendel AT hoth DOT amu DOT edu DOT pl CC: djgpp AT delorie DOT com In-reply-to: <01bc33c8$f05661c0$ae80dec2@default> Once upon a time (on 18 Mar 97 at 18:21) Alex said: > I am pretty new to DJGPP but I think it's great especially because it's > FREE!!! It has a lot of other advantages, and the more important ones ;-)) > I am trying to compile a program from a Tutorial that was written for > Borland C and at the top of the source code it say's: > "Remember to compile in the LARGE memory model!" > What is and how do I access this Memory Model??? LARGE model in DOS16 compilers is where you use FAR pointers for code (if necessary) and FAR pointers for data. That means a pointer consists of two parts SEGMENT:OFFSET16 and is 32 bits long. In protected mode, however, in which DJGPP works there is no need to use far pointers as every segment can span entire memory and you only need to use an offset into that memory which is also 32 bits. This is called a FLAT memory model - no other models are currently used. It is possible to use FAR pointers in protected mode, but they are 48 bits long rather than the RM 32 - SELECTOR:OFFSET32. Note that I used SELECTOR here, not SEGMENT. It's because in real mode the segment part of a pointer directly addresses the segment's placement in memory while in protected mode it is an index to an array of segment description structures. This is why you cannot use the RM values in PM pointers. Continued below... > I am using a P75 with 16mb with Win95, when I compile the program at the > moment and run it, this is what comes up: > > "General Protection Fault at eip=000021ba > eax=a0000000 ebx=00093603 ecx=00090004 edx=00000000 esi=0000011f > edi=0000002f > ebp=0004e4a4 esp=0004af30 program=C:\ALEX\DJ\MOUSE.EXE > cs: sel=00a7 base=85645000 limit=0009ffff > ds: sel=00b7 base=85645000 limit=0009ffff > es: sel=00b7 base=85645000 limit=0009ffff > fs: sel=0087 base=00019aa0 limit=0000ffff > gs: sel=00c7 base=00000000 limit=ffffffff > ss: sel=00b7 base=85645000 limit=0009ffff > > Call frame traceback EIPs: > 0x000021ba > 0x00002f8e" GPF means that your code tries to access data/code which lies outside the allowable boundaries. I suspect that the sample program you're trying to compile uses FAR pointers to access some data (supposedly some mouse driver structures judging from the exe name) which is illegal in PM for the reasons outlined above. To make it work (if you showed us the code it'd be easier to help) you must change all the memory referencing code to match DJGPP's scheme. ########################################################### We're terminal cases that keep taking medicine pretending the end isn't quite that near. We make futile gestures, act to the cameras with our made up faces and a PR smiles. And when the angel comes down to deliver us, we'll find out after all we're only men of straw. ---- Visit http://ananke.amu.edu.pl/~grendel