home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!mips!swrinde!elroy.jpl.nasa.gov!ames!pacbell.com!pbhya!dbsuthe
- From: dbsuthe@pbhya.PacBell.COM (Daniel B. Suthers)
- Newsgroups: comp.sys.atari.st.tech
- Subject: Re: Using Setexec() [a bit of help needed]
- Keywords: Setexec(), BIOS, vectors, AAARRRGGGGHHHH!
- Message-ID: <1992Aug17.175736.7804@pbhya.PacBell.COM>
- Date: 17 Aug 92 17:57:36 GMT
- References: <1992Aug17.083005.6390@aber.ac.uk>
- Reply-To: dbsuthe@PacBell.COM (Daniel B. Suthers)
- Organization: Pacific * Bell, San Ramon, CA
- Lines: 47
-
- In article <1992Aug17.083005.6390@aber.ac.uk> ssw@aber.ac.uk (Simon the Loony) writes:
- >Greetings,
- > I am currently writing a little program in C which requires that
- >certain errors, notably bus and address errors should be trapped. According to
- >my copy of ``Internals'', Setexec() (BIOS function 5) will do just that and is
- >defined thus : long Setexec(exec_no, vector)
- > int exec_no ;
- > long vector ;
- >
- [TEXT DELETED ]
- >The question is, what do I pass to Setexec() for the addresses of each of these
- >functions? According to my book on C, just taking the address of a function is
- >not allowed.....
- >
- Your book is (unfortunately) wrong. The following code should compile and
- execute under any C compiler. The name of a function evaluates to the
- address of the function just like the name of an array does.
-
-
- #include <stdio.h>
- main()
- {
- void (*jumpto)(); /* A pointer to a function. */
- void sec_on(); /* Declare that the sec_on function exists. */
-
- jumpto = sec_on; /* Set the pointer to the address of the function*/
- jumpto(); /* Execute the function that's at the address
- * pointed to by the pointer.
- */
- return(0);
- }
-
- void static sec_on() /* this is the silly little function */
- {
- printf(" this is sec_on()\n");
- }
-
- This is standard C stuff. Another good source of help with C is the group
- comp.lang.c. It is full of people who don't know GEM or TOS, but can answer
- C questions.
-
- Daniel B. Suthers, CCP
- Technology Consultant, PCS & IN Development Lab, Pac*Bell
- Voice: (510) 671-1325 UUCP: pacbell!pbeos!dbsuthe
- ================================================================================
- = Commit unexpected kindness and senseless acts of beauty. =
- ================================================================================
-