From: DavMac AT iname DOT com (Davin McCall) Newsgroups: comp.os.msdos.djgpp Subject: Re: DJGPP - real mode procedures. Date: Wed, 02 Jun 1999 08:00:32 GMT Organization: Monash Uni Lines: 59 Distribution: world Message-ID: <3754e382.12311460@newsserver.cc.monash.edu.au> References: <3754872e DOT 8090925 AT newsserver DOT cc DOT monash DOT edu DOT au> <3754DFB8 DOT C650C0F0 AT hitech DOT net DOT au> NNTP-Posting-Host: damcc5.halls.monash.edu.au X-Trace: towncrier.cc.monash.edu.au 928310398 7818 130.194.198.138 (2 Jun 1999 07:59:58 GMT) X-Complaints-To: abuse AT monash DOT edu DOT au NNTP-Posting-Date: 2 Jun 1999 07:59:58 GMT X-Newsreader: Forte Free Agent 1.1/32.230 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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 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 >#include >#include > >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/