From 7e0f021a9aec35fd8e6725e87e3313b101d26f5e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 27 Jan 2008 11:37:44 +0100 Subject: Initial import (2.0.2-6) --- reference/C/CONTRIB/SNIP/fndislot.c | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 reference/C/CONTRIB/SNIP/fndislot.c (limited to 'reference/C/CONTRIB/SNIP/fndislot.c') diff --git a/reference/C/CONTRIB/SNIP/fndislot.c b/reference/C/CONTRIB/SNIP/fndislot.c new file mode 100755 index 0000000..2999596 --- /dev/null +++ b/reference/C/CONTRIB/SNIP/fndislot.c @@ -0,0 +1,48 @@ +/* +** Originally published as part of the MicroFirm Function Library +** +** Copyright 1990, Robert B.Stout +** +** Subset version released to the public domain, 1992 +** +** Function to locate an unused user interrupt vector. +*/ + +#ifdef __ZTC__ + #include +#else + #include + #ifdef __TURBOC__ + #define GETVECT getvect + #define FAR far + #define INTERRUPT interrupt + #else /* assume MSC */ + #define GETVECT _dos_getvect + #define FAR _far + #define INTERRUPT _interrupt + #endif + #define FNULL (void (FAR *)())(0L) +#endif + +unsigned findIslot(void) +{ +#ifdef __ZTC__ + unsigned int_no, seg, ofs; + + for (int_no = 0x60; int_no < 0x6f; ++int_no) + { + int_getvector(int_no, &seg, &ofs); + if (0U == (seg | ofs)) + return int_no; + } +#else /* MSC/BC/TC */ + unsigned int_no; + + for (int_no = 0x60; int_no < 0x6f; ++int_no) + { + if (FNULL != (void (FAR *)())GETVECT(int_no)) + return int_no; + } +#endif + return 0; +} -- cgit v1.2.3-54-g00ecf