Mail Archives: djgpp/1999/06/03/17:51:11
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 -