This function returns the 32-bit linear base address of the specified segment.
To Call
AX = 0006h
BX = Selector
Returns
If function was successful:
Carry flag is clear.
CX:DX = 32-bit linear base address of segment
If function was not successful:
Carry flag is set.
Programmer's Notes
The following function compiles with Watcom C/C++ version 11.0 or later, and Microsoft Visual C/C++ version 4.0 or later:
// 32-bit linear base address from descriptor for selector
int dpmiGetSegmentBaseAddress(dpmiSelector sel, // selector for base address
unsigned long *pLinaddr) // (returned) address
{
unsigned long base; // base linear address of segment
int result; // zero if int 31h succeeds
unsigned short errorCode; // error code from DPMI host
__asm {
mov bx, sel // the selector to get base address of
mov eax, 0x006 // call dpmi host to do getting
int 0x31
mov errorCode, ax // save error code from DPMI, if any
sbb eax, eax // record success/failure flag
mov result, eax
mov eax, ecx // store cx:dx into base
shl eax, 16
mov ax, dx
mov base, eax
}
// if the dpmi call failed, return the dpmi error code
if (result != 0)
return errorCode;
// return obtained base address
*pLinaddr = base;
// indicate success
return 0;
}