delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/03/17:51:11

Message-ID: <3754E66F.21841599@hitech.net.au>
From: leroy <leroy AT hitech DOT net DOT au>
X-Mailer: Mozilla 4.5 [en] (Win98; I)
X-Accept-Language: en,ja
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DJGPP - real mode procedures.
References: <Pine DOT SUN DOT 3 DOT 91 DOT 990601094329 DOT 19912M-100000 AT is> <3754872e DOT 8090925 AT newsserver DOT cc DOT monash DOT edu DOT au> <3754DFB8 DOT C650C0F0 AT hitech DOT net DOT au> <3754e382 DOT 12311460 AT newsserver DOT cc DOT monash DOT edu DOT au>
Lines: 86
Date: Wed, 02 Jun 1999 18:08:15 +1000
NNTP-Posting-Host: 203.27.197.38
X-Complaints-To: abuse AT telstra DOT net
X-Trace: nswpull.telstra.net 928311258 203.27.197.38 (Wed, 02 Jun 1999 18:14:18 EST)
NNTP-Posting-Date: Wed, 02 Jun 1999 18:14:18 EST
Organization: Customer of Telstra Big Pond Direct
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I was under the impression that the function would push the values for you.

There's a slight problem with that method though.

I don't assume what asm routine I'm running.  Actually in most cases it won't
be my code that is running.  Its for a BASIC->C translater, and its for
emulating the CALL ABSOLUTE routine.

Another thing was, when I got rid of the pop bx it still crashed.  I'm guessing
it tripped up on the add ax, bx.

And I can't put retf, as I explained it wouldn't work with a simple
mov ax, 13h
retf
The computer would crash.

The whole thing is getting bloody annoying.

Thanks for you help though.

Cheers,

leroy.

Davin McCall wrote:

> Well then, change the "iret" to "retf" and the "pop bx" to "mov bx,
> [sp+4]" (or else, "mov bp, sp" followed by "mov bx, [bp+4]").
>
> In case I didn't explain clearly, the arguments are normally pushed
> *before* the return address. That means that your "pop bx" is
> destroying the return address.
>
> Davin.
>
> On Wed, 02 Jun 1999 17:39:36 +1000, leroy <leroy AT hitech DOT net DOT au> wrote:
>
> >Actually it was just my rushed attempt at rebuilding the routine I had. :)
> >
> >Also I tried for ages to get the routine to work, thinking that it was my
> >C code that was wrong.  It was only when AS said that retf was an unknown
> >386 instruction that I changed it to ret, then to iret when that didn't
> >work.
> >
> >Heres the program that technically should run, but prefers to lock up
> >Windows/DOS instead.
> >
> >/* Attempt at getting a real mode machine code call to work */
> >
> >#include <stdio.h>
> >#include <go32.h>
> >#include <dpmi.h>
> >
> >int main()
> >{
> > unsigned char asmroutine[] = {0x5b, 0xb8, 0x10, 0x00, 0x01, 0xd8, 0xcf};
> > int stack[1];
> > /* pop bx
> >  * mov ax, 13h
> >  * add ax, bx
> >  * iret
> >  */
> > int sel = 0, seg = 0;
> > __dpmi_regs r;
> >
> > seg = __dpmi_allocate_dos_memory(2, &sel);
> > dosmemput(asmroutine, 4, (seg * 16));
> >
> > memset(&r, 0, sizeof(r));
> >
> > r.x.cs = seg;
> > /* I'm not sure about the stack[0] << 8 part, but it shouldn't matter */
> > stack[0] = 0x10 << 8;
> > __dpmi_simulate_real_mode_procedure_retf_stack(&r, 2, stack);
> >
> > printf("Value of ax now: 0x%s\n", itoa(r.x.ax, NULL, 16));
> >}
> >
> >Cheers,
> >
> >leroy.
>
> __________________________________________________________
>        *** davmac - sharkin'!! davmac AT iname DOT com ***
> my programming page: http://yoyo.cc.monash.edu.au/~davmac/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019