22.02.2014 Views

with DOS/4GW? - Open Watcom

with DOS/4GW? - Open Watcom

with DOS/4GW? - Open Watcom

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>DOS</strong> Programming Guide<br />

0x0021 function to create a directory. The string of characters are used to provide the<br />

directory name. This example can be adapted to handle most real-mode interrupt calls that<br />

aren’t supported in protected mode.<br />

/*<br />

SIMULATE.C - Shows how to issue a real-mode interrupt<br />

from protected mode using DPMI call 300h. Any buffers<br />

to be passed to <strong>DOS</strong> must be allocated in <strong>DOS</strong> memory<br />

This can be done <strong>with</strong> DPMI call 100h. This program<br />

will call <strong>DOS</strong> int 21, function 39h, "Create<br />

Directory".<br />

Compile & Link: wcl386 /l=dos4g simulate<br />

*/<br />

#include <br />

#include <br />

#include <br />

#include <br />

static struct rminfo {<br />

long EDI;<br />

long ESI;<br />

long EBP;<br />

long reserved by system;<br />

long EBX;<br />

long EDX;<br />

long ECX;<br />

long EAX;<br />

short flags;<br />

short ES,DS,FS,GS,IP,CS,SP,SS;<br />

} RMI;<br />

void main()<br />

{<br />

union REGS regs;<br />

struct SREGS sregs;<br />

int interrupt no=0x31;<br />

short selector;<br />

short segment;<br />

char far *str;<br />

/* DPMI call 100h allocates <strong>DOS</strong> memory */<br />

memset(&sregs,0,sizeof(sregs));<br />

regs.w.ax=0x0100;<br />

regs.w.bx=0x0001;<br />

int386x( interrupt no, &regs, &regs, &sregs);<br />

segment=regs.w.ax;<br />

selector=regs.w.dx;<br />

/* Move string to <strong>DOS</strong> real-mode memory */<br />

str=MK FP(selector,0);<br />

fstrcpy( str, "myjunk" );<br />

/* Set up real-mode call structure */<br />

memset(&RMI,0,sizeof(RMI));<br />

RMI.EAX=0x00003900; /* call service 39h ah=0x39 */<br />

RMI.DS=segment; /* put <strong>DOS</strong> seg:off into DS:DX*/<br />

RMI.EDX=0; /* <strong>DOS</strong> ignores EDX high word */<br />

36 How Do I Simulate a Real-Mode Interrupt <strong>with</strong> <strong>DOS</strong>/<strong>4GW</strong>?

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!