Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!wasatch!helios.ee.lbl.gov!ux1.lbl.gov!mikec From: mikec@ux1.lbl.gov (Mike Chin) Newsgroups: comp.lang.c Subject: Set function address into absolute memory? Keywords: vector table Message-ID: <2954@helios.ee.lbl.gov> Date: 7 Jul 89 01:02:02 GMT Sender: usenet@helios.ee.lbl.gov Distribution: usa Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 46 Is there a reasonable way to place the address of a function into an absolute location? I need to do this to set up the vector table in an 80186. I would have thought that something like "a pointer to a function" set to the table address would work, but it seems I have to wrap it inside of a structure. Here's an example that shows the structure, and in comments what seems should be OK. This lints with Gimpel, and runs under MSC 5.1 in large model... ---------------------------------------------------- /* instead of malloc, for an real vector table I would use absolute addresses */ #include #include typedef struct { void (*oopa)(); }functype; void vector(); void main() { void (*funcpoint)(); functype *funcstruct; /* this won't pass lint funcpoint=(void*) malloc (4); *funcpoint = vector; *funcpoint(); */ funcstruct=(functype *) malloc(4); funcstruct->oopa=vector; funcstruct->oopa(); } void vector() { printf ("this is the stuff\n"); } ---------------------------------------------------- Mike Chin MJChin@lbl.gov