[comp.os.msdos.programmer] far call in C

saunders@carina.unm.edu (Richard Saunders CIRT) (07/07/90)

   Help!  Some application interfaces, like XMS and Netware IPX/SPX, are
called with FAR CALLs instead of software interrupts.  This poses no problem
to assembly language programmers, but I'm working in C and I'm pretty
inexperienced at 8086 assembly language.  I need something similar to int86()
and int86x() that will let me load the various registers, do a far call, and
then examine the register contents in Microsoft C 5.0 || Mix Power C.
   Surely I'm not the first to face this problem...

      -- Richard Saunders

kdq@demott.COM (Kevin D. Quitt) (07/08/90)

In article <1990Jul7.100712.7027@ariel.unm.edu> saunders@carina.unm.edu (Richard Saunders CIRT) writes:
>
>   Help!  Some application interfaces, like XMS and Netware IPX/SPX, are
>called with FAR CALLs instead of software interrupts.  This poses no problem
>to assembly language programmers, but I'm working in C and I'm pretty
>inexperienced at 8086 assembly language.  I need something similar to int86()
>and int86x() that will let me load the various registers, do a far call, and
>then examine the register contents in Microsoft C 5.0 || Mix Power C.
>   Surely I'm not the first to face this problem...

    If the XMS and Netware libraries are written for C, then you need
only compile in large model (/AL) or declare the functions your are
using as far functions: e.g. 

extern void far function_foo();

    If they require values placed in specific registers, then you'll need
an assembly routine - but only one.  Declare the function as above, and:

call_far_fn( function_foo, ax, bx, cx, dx );

where call_far_fn is an asembly routine that loads up the registers
as specified, then does the far call, and passes the return value back
to C (generally in AX, or DX:AX).

    You could even define a macro like:

#define	FN_foo(a, b, c, d)  call_far_fn( function_foo, (a), (b), (c), (d))

    then invoke it like:

FN_foo( ax, bx, cx, dx );


    Good luck!

-- 
 _
Kevin D. Quitt         demott!kdq   kdq@demott.com
DeMott Electronics Co. 14707 Keswick St.   Van Nuys, CA 91405-1266
VOICE (818) 988-4975   FAX (818) 997-1190  MODEM (818) 997-4496 PEP last

                96.37% of all statistics are made up.