From: DavMac AT iname DOT com (Davin McCall) Newsgroups: comp.os.msdos.djgpp Subject: Re: DJGPP - real mode procedures. Date: Wed, 02 Jun 1999 11:23:42 GMT Organization: Monash Uni Lines: 39 Distribution: world Message-ID: <3755143d.1587602@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 928322590 1513 130.194.198.138 (2 Jun 1999 11:23:10 GMT) X-Complaints-To: abuse AT monash DOT edu DOT au NNTP-Posting-Date: 2 Jun 1999 11:23:10 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 Another problem is that "dosmemput" is only being used to copy four bytes, whereas there should be six... however, there is still the "pop bx" and the "iret" to be fixed *really* - I even tried it. Your code crashed my machine spectacularly, but the following code works fine: #include #include #include int main() { unsigned char asmroutine[] = {0x89, 0xE5, 0x8B, 0x46, 0x04, 0x05, 0x13, 0x00, 0xCB}; int stack[1]; /* mov bp, sp * mov ax, [bp+4] * add ax, 13h * retf */ int sel = 0, seg = 0; __dpmi_regs r; seg = __dpmi_allocate_dos_memory(2, &sel); dosmemput(asmroutine, 9, (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] = 0x100; __dpmi_simulate_real_mode_procedure_retf_stack(&r, 2, stack); printf("Value of ax now: 0x%s\n", itoa(r.x.ax, NULL, 16)); } __________________________________________________________ *** davmac - sharkin'!! davmac AT iname DOT com *** my programming page: http://yoyo.cc.monash.edu.au/~davmac/