home *** CD-ROM | disk | FTP | other *** search
- /*
- This example shows how to access the resident library functions
- provided in RESLIB.EXE. This program is set up to use small model.
- */
-
- #include "tsr.h"
- #include "resproto.h"
- #include "stdio.h"
- #include "conio.h"
- #include "process.h"
- #include "dos.h"
-
- int far *reslib_vector;
-
- void main()
- {
- union REGS inregs, outregs;
- struct SREGS insregs;
- int i;
-
- char *mystr1 = " /* Resident_C */ ";
- char *mystr2 = " LIBDEMO demo ! ";
-
- /* Get address (offset) part of char pointers into dx and cx. */
- /* The segment part of address is the default ds register because */
- /* we are compiling in small model. We get the default ds with the */
- /* segread call below. If we were large data model, we could use the */
- /* FP_SEG and FP_OFF macros in dos.h to get the segment and offset. */
-
- inregs.x.dx = (unsigned)mystr1;
- inregs.x.cx = (unsigned)mystr2;
-
- segread(&insregs);
- insregs.es = insregs.ds;
-
- /* find reslib vector using tsrshare() */
-
- i = tsrshare(0x4757,(void far *) &reslib_vector);
- if( i != 0)
- {
- printf(" RESLIB not loaded!\n");
- exit(1);
- }
-
- printf("call function 0 to print registers used\n");
- inregs.h.ah = 0;
- int86x(*reslib_vector, &inregs, &outregs, &insregs);
-
- inregs.h.ah = 1;
- printf("string 1 =");
- int86x(*reslib_vector, &inregs, &outregs, &insregs);
-
- inregs.h.ah = 2;
- printf("string 2 =");
- int86x(*reslib_vector, &inregs, &outregs, &insregs);
-
- inregs.h.ah = 3;
- int86x(*reslib_vector, &inregs, &outregs, &insregs);
- printf("compare of strings = %d\n", outregs.x.ax);
-
- inregs.h.ah = 4;
- int86x(*reslib_vector, &inregs, &outregs, &insregs);
- inregs.h.ah = 3;
- int86x(*reslib_vector, &inregs, &outregs, &insregs);
- printf("compare of strings after copy = %d\n", outregs.x.ax);
-
- inregs.h.ah = 5;
- int86x(*reslib_vector, &inregs, &outregs, &insregs);
- printf("length of string 1 = %u\n", outregs.x.ax);
-
- }
-