X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: Eph Newsgroups: comp.os.msdos.djgpp Subject: Re: calling a RM function which is placed below 1 MB Date: Thu, 24 Jul 2008 03:56:42 -0700 (PDT) Organization: http://groups.google.com Lines: 113 Message-ID: <002f1dec-45b2-4304-96fe-8c44371cc026@d45g2000hsc.googlegroups.com> References: NNTP-Posting-Host: 80.70.169.36 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1216897002 5279 127.0.0.1 (24 Jul 2008 10:56:42 GMT) X-Complaints-To: groups-abuse AT google DOT com NNTP-Posting-Date: Thu, 24 Jul 2008 10:56:42 +0000 (UTC) Complaints-To: groups-abuse AT google DOT com Injection-Info: d45g2000hsc.googlegroups.com; posting-host=80.70.169.36; posting-account=jZZPxgoAAAAqQ_zmNV7SH4j6l4lfRyOd User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 abgpro01 (NetCache NetApp/6.0.6) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id m6OB04pI005045 Reply-To: djgpp AT delorie DOT com On 24 Jul., 10:30, Eph wrote: > Thx for your hint. I thought: > > memset(®s, 0, sizeof(__dpmi_regs)); > > Zeros it all so this should not matter isn't it? > > Ciao Ephraim > > On 23 Jul., 20:45, "Rod Pemberton" wrote: > > > "Eph" wrote in message > > >news:ca0df607-1be3-4358-b84f-f0ccddde3197 AT d77g2000hsb DOT googlegroups DOT com... > > > > I've problems to get a call to > > > __dpmi_simulate_real_mode_procedure_retf_stack working correctly. > > > My problem is, that I need to call a 16Bit real Mode function placed > > > in Memory below 1MB, which expects three parameters to be placed on > > > the RM Stack.(see comments in the code). > > > > Below the code, how I tried to use the function: > > > > --------------- > > > __dpmi_regs regs; > > > struct { > > > unsigned long u1; > > > unsigned long u2; > > > unsigned long u3; > > > } stack; > > > > memset(&stack, 0, sizeof(stack)); > > > > stack.u1 = parm1; // expected at bp[14] > > > stack.u2 = parm2; // expected at bp[10] > > > stack.u3 = parm3; // expected at bp[06] > > > > memset(®s, 0, sizeof(__dpmi_regs)); > > > > regs.x.cs = seg; // segment of the function entry > > > regs.x.ip = ofs; // offset of the function entry > > > DPMI 0.9 says ss:sp must be zero for the DPMI host to provide a real mode > > stack, or ss:sp must point to a valid real mode stack.  DJGPP doc's > > (libc.info) say ss:sp and flags must be set to valid values or zero. > > > regs.x.ss=0; > > regs.x.sp=0; > > > The DJGPP doc's don't state which "flags" must be set (DPMI or __dpmi_regs): > > > regs.x.flags=0; /* __dpmi_regs  flags */ > > regs.h.bh=0; /* DPMI flags */ > > > But, it's likely the doc's were referring to the DPMI flags...  (BH bit 0 = > > 1 resets A20 and PIC)  You'll also need to set any other registers that the > > function uses since the call copies _all_ registers. > > > > __dpmi_simulate_real_mode_procedure_retf_stack(®s, sizeof(stack) / > > > 2, &stack); > > > --------------- > > > > What am I doing wrong? > > > Not sure. > > > > Can anyone please point it out! > > > Try the above.  Let us know. > > > Rod Pemberton No that was not the problem :(. The Stack configuration is ok? I'm not sure about the struct and the order I must place the params. But the comments say how it should be. param1 must be at bp[14] and must be a DWORD PTR. param2 must be at bp[10] and must be a DWORD PTR. param3 must be at bp[06] and must be a DWORD PTR. param1 - 3 are allocated like this: typedef struct MEM_INFO { void *data; int selector; int segment; unsigned long base; int size; }; #define BYTE2PARAGRAPH(a) ((a+15)>>4) void myAlloc(MEM_INFO* mi) { mi->data = (void*)malloc(mi->size); mi->segment = __dpmi_allocate_dos_memory(BYTE2PARAGRAPH(mi->size), &mi->selector); __dpmi_set_segment_base_address(mi->selector, mi->base); __dpmi_set_segment_limit(mi->selector, mi->size); memset(mi->data, 0, mi->size); } And I use the data as a pointer for my program and before the function call I do three dosmemput(data, size, base); and the base part of the three params are the unsigned long's I give to the RM function. I would be glad for any help. Ciao Ephraim