Date: Fri, 29 Jan 1999 09:13:40 -0500 Message-Id: <199901291413.JAA03754@envy.delorie.com> From: DJ Delorie To: djgpp AT delorie DOT com In-reply-to: <19990129135316.3561.qmail@hotmail.com> (msdawy@hotmail.com) Subject: Re: paradox! References: <19990129135316 DOT 3561 DOT qmail AT hotmail DOT com> Reply-To: djgpp AT delorie DOT com > 1) what is _djgpp_conventional_base? This is the amount you have to add to pointers to make them point to physical addresses instead of logical addresses, when using nearptr.h. For example, to point to the VGA memory you'd use this: (char *)(0xa0000+_djgpp_conventional_base) > the 386 has some models of operation. of which i am only interested in > two, the segmented model, and the flat model. I have understood that the > flat model is the same as the segmented but with all segments set to the > same values (i.e. they all point to the same descriptor). they all begin > at 0 and span 4gb, right? No. The 386 has three modes of operation: real, protected, and V86. We're only interested in protected. Protected mode programs, like *all* 386 programs, are always segmented. "flat model" only means that CS=DS=ES=SS and that, for the most part, programs may simply ignore the fact of segments. Flat mode does not mean that the base address is zero and that the segments are 4Gb large. In fact, with DJGPP's flat model, neither of these are true. Using nearptr.h makes the segments 4G each, but does not make them start at physical address 0. > a) is there any kind of protection when using the flat mode? how comes? Yes. You are still running in protected mode. > all the memory is available and i can write to anywhere without causing > an exception! Wrong! > b) I assume djgpp runs in flat model! right? Yes. However, your definition of "flat model" is incorrect. Think of Borland's "tiny model" instead, but with 32 bits of space instead of 16. > >Programs compiled with DJGPP can access all the physical memory on your > >machine That doesn't mean you can scribble all over existing programs or the OS. They will let you use all available physical memory, but they will protect themselves against corruption. > great... now all the memory is available! why do i get a SIGSEGV fault > when i executed a very simple CLS function? > mov edi,0xa0000 > mov ecx,16000 > mov eax,0 > rep stosd Because you are asking to write to memory that you haven't correctly referenced. You made a mistake, and the OS will stop you rather than let you crash the system. Since DJGPP segments don't start at physical address 0, you can't just make up linear addresses like that and expect them to point to physical devices. > 3) where can i find info about pages, page table... etc... i have read > intel reference, but i couldn't understand any thing!! :-( The Intel "system programmer's guide" is the best reference I know for all that, but it is a complicated thing to learn. Fortunately, unless you're writing an operating system, you won't need to know anything about it.