Date: Sat, 5 Aug 1995 09:29:49 -0400 From: dj (DJ Delorie) To: mwilczyn AT romulus DOT rutgers DOT edu Cc: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Re: Near Pointers in DJGPP 2.0 > I'm new to protected mode and have a problem with pointers. I > thought that the whole point of protected mode was to get a flat > memory model. This way you wouldn't have to deal with segments. > But it seems that I still have to use segments (selectors in this > case) to access memory. Shouldn't you be able to just specify > an absolute address and access any memory on your system? No, there's still the issue of memory protection. You can only access the memory in your program's address space. > For example, I want to write data to a device that maps it's > buffer at 2560MB. Is there any way to use a NEAR (offset only) > pointer to access this memory in DJGPP? If I put 0xA0000000 > into %edi I should be able to access it? Some C or assembler > examples would be nice. In V2, there's a way that works with some DPMI providors but not all. If you have DPMI 1.0, there's a function call to allow this, but most DPMI are 0.9, which don't. See for more info. The thing to remember is that you *are* in a segment, and offset zero in your segment is not physical offset zero, so you can't just calculate near pointers the easy way. The Intel processors (80x86) always use segments. Sometimes, there are many fewer segments to deal with. For most djgpp programs, there are few enough that you don't have to deal with them at all. Sometimes, though, like when dealing with hardware or interrupts, you need to use segments to access them.