X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: "Rod Pemberton" Newsgroups: comp.os.msdos.djgpp Subject: Re: calling a RM function which is placed below 1 MB Date: Wed, 23 Jul 2008 14:45:30 -0400 Organization: Aioe.org NNTP Server Lines: 61 Message-ID: References: NNTP-Posting-Host: mQokHQeKeRC37oD/Mq9UYg.user.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse AT aioe DOT org X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1914 X-Newsreader: Microsoft Outlook Express 6.00.2800.1914 X-Priority: 3 X-MSMail-Priority: Normal To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "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