Mail Archives: djgpp/2002/02/14/05:27:41
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 <sys/types.h>
#include <sys/movedata.h>
#include <dpmi.h>
#include <go32.h>
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");
}
- Raw text -