From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Protected Mode programming Date: Thu, 29 May 1997 20:43:09 +0000 Organization: Two pounds of chaos and a pinch of salt Message-ID: <338DEA5D.4569@cs.com> References: <338db41a DOT 6844334 AT news DOT pcisys DOT net> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp109.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 60 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk IEX & SAMPLE wrote: > > Hello, I'm new to DJGPP and protected-mode programming, I was > wondering how do I use protected mode? Do programs made w/ DJGPP > automatically go into protected mode when they are run?? Yes. And you don't need to worry about it at all unless you start performing hardware-dependent operations, such as graphics and interrupt handling. In that case, the techniques you learned for real-mode compilers will NOT work, and either won't compile or will crash your programs. Please get and read the DJGPP Frequently Asked Questions list (v2/faq210b.zip), which explains a great deal of this stuff and gives you pointers and examples of things to watch out for in protected mode. But just for kicks, try the following program: /* lotsamem.c */ #include #include int main( void ) { char *p; int megs; printf( "How many megabytes would you like to allocate (1-256)? " ); if ( scanf( "%d", &megs ) < 1 || megs < 1 || megs > 256 ) printf( "That's not what I asked for, dufus.\n" ); else { p = malloc( megs * 1048576 ); if ( p != NULL ) { printf( "Wow! You just allocated %d megabytes!\n", megs ); free( p ); } else printf( "Whoops! You don't have enough memory available. Sorry.\n" ); } return 0; } Compile it by typing "gcc -o lotsamem.exe lotsamem.c". Run it by typing "lotsamem". Enjoy. ;) Note: depending on what DPMI host you run under (cwsdpmi, Windows, Linux, OS/2, QDPMI, etc.), you may have varying amounts of free memory and may not be able to allocate it all in one chunk. But that's an advanced topic. -- --------------------------------------------------------------------- | John M. Aldrich, aka Fighteer I | mailto:fighteer AT cs DOT com | | "Starting flamewars since 1993" | http://www.cs.com/fighteer | | *** NOTICE *** This .signature is generated randomly. | | If you don't like it, sue my computer. | ---------------------------------------------------------------------