Message-Id: <199703041954.NAA143876@audumla.students.wisc.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Tue, 04 Mar 1997 13:55:26 -0600 To: djgpp AT delorie DOT com From: Scott Fleischman Subject: Re: __djgpp_base_address > >On Mon, 3 Mar 1997, Scott Fleischman wrote: > >> I am wondering why this code works fine in the Win95 Dos box, yet doesn't >> work under Win95 msdos mode w/ cwsdpmi or in dos 6.22 w/ qemm unless I >> change the line: >> info.address = (long) addr + __djgpp_base_address; >> to >> info.address = (long) addr - __djgpp_base_address; >> (or "... + __djgpp_conventional_base" since they are equivalent.) > >Why, because that's how you should use nearptrs! The correct way is >to add the `__djgpp_conventional_base', NOT `__djgpp_base_address' (it >is documented that way in the libc reference). You should never mess >with `__djgpp_base_address' anyway. > >And btw, you should take the value of `__djgpp_conventional_base' >immediately after a call to `__djgpp_nearptr_enable'. Your code calls >`sbrk' between these two, which is unsafe (`sbrk' will sometimes move >the base address). > Thank you for your reply but I diagree with never using __djgpp_base_address, and in this case it is the right thing to use. If I use __djgpp_conventional_base it doesn't work. But if instead I wanted something like the address for 0xa0000 I would add __djgpp_conventional_base to it. Anyway, I got it to work right and here is the code (just in case you wish to see it). #include #include #include int main() { int i, j, checksum; __dpmi_meminfo info; info.size = (__djgpp_selector_limit + 1) - 4096; info.address = __djgpp_base_address + 4096; if (__dpmi_lock_linear_region(&info)) { printf ("Couldn't lock text and data\n"); return 0; } /* touch the entire image */ for (j=0 ; j<4 ; j++) { for(i=0x1000 ; i<(info.size - 16 * 0x1000) ; i += 4) { checksum += *(int *)i; checksum += *(int *)(i + 16 * 0x1000); } } printf("%d Kb locked.\n", info.size / 1024); return 0; }