DOS/32 Advanced DOS Extender - Programmer's Reference

2.25 - DPMI function 0302h - Call Real Mode Procedure With IRET Frame

Simulates a FAR CALL with flags pushed on the stack to a real mode procedure. The real mode routine must return by executing an IRET instruction.



AX = 0302h
BH = flags (must be 0)
CX = number of words to copy from protected mode to real mode stack
ES:EDI = selector:offset of real mode register data structure in the following format:

 Offset  Length  Contents
 00h  4  EDI
 04h  4  ESI
 08h  4  EBP
 0Ch  4  reserved, should be zero
 10h  4  EBX
 14h  4  EDX
 18h  4  ECX
 1Ch  4  EAX
 20h  2  CPU status flags
 22h  2  ES
 24h  2  DS
 26h  2  FS
 28h  2  GS
 2Ah  2  IP
 2Ch  2  CS
 2Eh  2  SP
 30h  2  SS


if successful:
CF clear
ES:EDI = selector:offset of modified real mode register data structure

if failed:
CF set
AX = error code

8012h - linear memory unavailable (stack)
8013h - physical memory unavailable (stack)
8014h - backing store unavailable (stack)
8021h - invalid value (CX too large)


a) The CS:IP in the real mode register data structure specifies the address of the real mode procedure to call.

b) If the SS:SP fields in the real mode register data structure are zero, a real mode stack will be provided by the DPMI host. Otherwise, the real mode SS:SP will be set to the specified values before the interrupt handler is called.

c) The flags specified in the real mode register data structure will be pushed on the real mode stack's IRET frame. The procedure will be called with the interrupt and trace flags clear.

d) Values placed in the segment register positions of the data structure must be valid for real mode; ie the values must be paragraph addresses and not selectors.

e) All general register fields in the data structure are DWORDs so that 32-bit registers can be passed to real mode.

f) The target real mode handler or procedure must return with the stack in the same state as when it was called. This means that the real mode code may switch stacks while it is running, but must return on the same stack that it was called on and must return with an IRET or discard the flags from the stack with a RETF(2) .

g) When this function returns, the real mode register data structure will contain the values that were returned by the real mode procedure. The CS:IP and SS:SP values will be unmodified in the register data structure.

h) It is the caller's responsibility to remove any parameters that were pushed on the protected mode stack.


Copyright Supernar Systems, Ltd. 1996-2005
All Rights Reserved.