X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f Date: Thu, 14 Feb 2002 12:26:48 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Altaf cc: djgpp AT delorie DOT com Subject: Re: Need help with FP_SEG and FP_OFF In-Reply-To: <3C6B356D.710D406F@charter.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Wed, 13 Feb 2002, Altaf wrote: > I have just started to port an old 16bit code to DJGPP'c gcc compiler. > I have a small segment of code which I can not port. I ueses SREGS > structure. > > Here is an example. If someone can look at it and let me know how to > translate into DJGPP's. I have been reading FAQ section 17.6 and 18.2 > and more. BUT I am still not being able to solve the mystery of > register. Could you please be more specific about what's missing in the FAQ? There's a working example of code in section 18.2 that should explain how to write such code. What is unclear about it that prevented you from rewriting your code for DJGPP yourself? I attach below the (untested) DJGPP version of your code. Can you tell what parts of the code below need some knowledge that is not in section 18.2's text and example? > My problem area is: > FP_SEG and FP_OFF(). DJGPP does not have these two functions. > Can I write my own? OR Can I somehow translate them into DJGPP. As the FAQ tells, you don't need FP_OFF and FP_SEG. Here's the code; any questions? I've put comments where your code is incomplete. Also, I suggest to read section 18.5 carefully, since your code seems to pass structures to a real-mode service. #include #include #include #include int someFn(someStruct *profileptr) { __dpmi_regs r; unsigned char *fdata; fdata = (char *)profileptr; printf("fdata in setprofile: [%s] \n", fdata); printf("fdata in setprofile: [%s] \n", fdata); r.h.ah = 0x44; r.h.al = 0x03; /* could have simply said "r.x.ax = 0x4403;" instead */ r.x.bx = handle; /* this is undeclared: a possible bug */ /* You need to pass profile_size, the size of the structure someStruct in bytes. */ dosmemput (profileptr, profile_size, _tb); r.x.ds = _tb >> 4; r.x.dx = _tb & 0x0f; r.x.cx = SETPROFILE; __dpmi_int (0x21, &r); /* Error checking missing here. You should at least look at (r.x.flags & 1), the carry flag: if it's set, the call failed. */ printf("End of setprofile \n"); }