Category : Assembly Language Source Code
Archive   : XLIB20.ZIP
Filename : EXAMPLE2.C

 
Output of file : EXAMPLE2.C contained in archive : XLIB20.ZIP

#include
#include
#define som _emit 0x66 /* switch operand mode */
#define sam _emit 0x67 /* switch address mode */
long __far getextmem(long address);

int goterr = 0; /* error flag */

main()
{
long l;
l = INITXLIB(); /* initialize XLIB */
if(l != 0)
{
printf("Library initialization error: %lX",l);
return 0;
}
l = getextmem(0x100000); /* read first address in 2ond meg */
if(goterr != 0)
{
printf("Inline mode-switch error: %lX",l);
return 0;
}
printf("%lX\n",l);
}

long __far getextmem(long address)
{
__asm
{
som ;mov eax,[bp+6]
mov ax,[bp+6] ; ""
call INLINEPM
jc error ;Error code in ax
mov ds,es:FLATDSEL
sam ;push dword ptr [eax]
som ; ""
_emit 0ffh ; ""
_emit 030h ; ""
pop ax
pop dx
call es:INLINERMPTR
jmp done
error:
xor dx,dx ;Return error code in dx:ax
inc goterr
done:
}
}