Date: Wed, 5 Mar 1997 07:43:21 +0200 (IST) From: Eli Zaretskii To: Christoph Kukulies cc: djgpp AT delorie DOT com Subject: Re: dpmi_int - any caveats? In-Reply-To: <199703031534.QAA12308@gil.physik.rwth-aachen.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Mon, 3 Mar 1997, Christoph Kukulies wrote: > > On Mon, 3 Mar 1997, Christoph Kukulies wrote: > > > > > I read djgppfaq.txt chapter 18.2 and as a result I thought I > > > had it working but the combo of my program and the driver > > > seems to be very unstable. I cannot invoke the program twice. [snip] > #define X(x) *((char *)__tb) = x&0xff;*((char *)__tb+1)=(x>>8)&0xff;\ > *((char *)__tb+2) = (x>>16)&0xff;*((char *)__tb+3)=(x>>24)&0xff; > > printf(" %08lx %08lx %08lx\n", > *((unsigned long *)__tb+0), > *((unsigned long *)__tb+1), > *((unsigned long *)__tb+2)); The above two snippets from your program (and their likes) are the source of your trouble. You can't treat `__tb' as if it were an address of a C variable, because it is outside the usual DJGPP address space. (The FAQ explains in section 18.4 what does ``DJGPP address space'' mean.) Whereas a C variable or buffer are referenced using the DS selector (or SS, if they are on the stack), `__tb' needs a special selector that can access the conventional memory. That's what functions like `_farpeekl' and `_farpokew' are for; you should use them to put data to and get data from the transfer buffer. (`dosmemput' and `dosmemget' are other possible ways of doing this, but in your case farptr functions are more appropriate, since you only move words or double-words.) For example, here's the definition of X() that should work (I didn't actually test it with your program, though): #define X(x) _farpokel(_dos_ds, __tb, (long)(x)) (`_dos_ds' is that special selector that should be used to access conventional memory addresses.)