home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / atari / st / tech / 4451 < prev    next >
Encoding:
Text File  |  1992-08-17  |  2.3 KB  |  60 lines

  1. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!mips!swrinde!elroy.jpl.nasa.gov!ames!pacbell.com!pbhya!dbsuthe
  2. From: dbsuthe@pbhya.PacBell.COM (Daniel B. Suthers)
  3. Newsgroups: comp.sys.atari.st.tech
  4. Subject: Re: Using Setexec() [a bit of help needed]
  5. Keywords: Setexec(), BIOS, vectors, AAARRRGGGGHHHH!
  6. Message-ID: <1992Aug17.175736.7804@pbhya.PacBell.COM>
  7. Date: 17 Aug 92 17:57:36 GMT
  8. References: <1992Aug17.083005.6390@aber.ac.uk>
  9. Reply-To: dbsuthe@PacBell.COM (Daniel B. Suthers)
  10. Organization: Pacific * Bell, San Ramon, CA
  11. Lines: 47
  12.  
  13. In article <1992Aug17.083005.6390@aber.ac.uk> ssw@aber.ac.uk (Simon the Loony) writes:
  14. >Greetings,
  15. >    I am currently writing a little program in C which requires that 
  16. >certain errors, notably bus and address errors should be trapped. According to
  17. >my copy of ``Internals'', Setexec() (BIOS function 5) will do just that and is
  18. >defined thus :        long Setexec(exec_no, vector)
  19. >            int    exec_no ;
  20. >            long    vector ;
  21. >
  22.   [TEXT DELETED ]
  23. >The question is, what do I pass to Setexec() for the addresses of each of these
  24. >functions? According to my book on C, just taking the address of a function is
  25. >not allowed.....
  26. >
  27. Your book is (unfortunately) wrong.  The following code should compile and
  28. execute under any C compiler.  The name of a function evaluates to the
  29. address of the function just like the name of an array does.
  30.  
  31.  
  32. #include <stdio.h>
  33. main()
  34. {
  35.    void (*jumpto)();        /* A pointer to a function. */
  36.    void sec_on();        /* Declare that the sec_on function exists. */
  37.  
  38.    jumpto = sec_on;    /* Set the pointer to the address of the function*/
  39.    jumpto();        /* Execute the function that's at the address
  40.              * pointed to by the pointer.
  41.              */
  42.    return(0);
  43. }
  44.  
  45. void static sec_on()        /* this is the silly little function */
  46. {
  47.   printf(" this is sec_on()\n");
  48. }
  49.  
  50. This is standard C stuff.  Another good source of help with C is the group 
  51. comp.lang.c.  It is full of people who don't know GEM or TOS, but can answer 
  52. C questions.
  53.  
  54. Daniel B. Suthers,  CCP
  55. Technology Consultant, PCS & IN Development Lab,        Pac*Bell
  56. Voice: (510) 671-1325               UUCP:  pacbell!pbeos!dbsuthe
  57. ================================================================================
  58. =  Commit unexpected kindness and senseless acts of beauty.                    =
  59. ================================================================================
  60.