Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!DEVELOPMENT.WATSTAR.UWATERLOO.CA!erick From: erick@DEVELOPMENT.WATSTAR.UWATERLOO.CA Newsgroups: comp.protocols.tcp-ip.ibmpc Subject: (none) Message-ID: <9104112354.AA26361@watserv1.uwaterloo.ca> Date: 12 Apr 91 00:50:48 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 43 John Haskey wrote: >Does anyone out there have some example code that shows how to talk to a >packet driver from Turbo C? I can get everything going except for the >most important: The receiver routine specified in the call to access_type(). The following is Turbo C code which seems to work with every packet driver I've tried. Remember, you could be running with VERY LITTLE stack space, so don't use very few local variables, avoid function calls and avoid DOS and the BIOS. This version saves all the registers on the stack as integers. I have only tested this in small model, and notice how Turbo C correctly converts the pointer to 32 bits. typedef struct farcallstr{ UCHAR pushf; UCHAR callfar; void interrupt (*introutine)(); UCHAR retf; }; void interrupt ourint(bp,di,si,ds,es,dx,cx,bx,ax,ip,cs,flgs) { switch ( ax ) { case 0 : /* initial call - allocate a buffer */ break; case 1 : /* indicates packet is ready */ break; } } struct farcallstr farcall = { 0x9c, 0x9a, ourint, 0xcb}; When you do the packet driver installation, remember to set es to FP_SEG( &farcall). Turbo C will return the correct segment. To transfer the parameters, you should probably use intr() rather than _ES, _DS and the inline geninterrupt() which may fail when some drivers do not restore the segment registers. Good luck. Erick