Help with interrupt handler

This is a discussion on Help with interrupt handler within the C Programming forums, part of the General Programming Boards category; Hi everyone, What does this attribute do? Code: void __attribute__ ((interrupt)) context_switch (void) { ... } What I undrestand is ...

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    52

    Help with interrupt handler

    Hi everyone,

    What does this attribute do?

    Code:
    void __attribute__ ((interrupt)) context_switch (void)
    {
    ...
    }
    What I undrestand is that it basically does a return from interrupt (rti) assembly instruction for you.

    so this would be the same:

    Code:
    void context_switch (void)
    {
    ...
     volatile asm ("rti")
    }
    When I try this though! I get a program stopped with signal 4 error

    So the __attribute__ ((interrupt)) must be doing more than an RTI instruction to return where it was.

    Any help appreciated.

    Ted

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,687
    Compile the code with gcc -S
    Then study the assembler.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can't pin down bug related to timer interrupt handler.
    By jalnewbie in forum C Programming
    Replies: 2
    Last Post: 11-21-2006, 01:05 PM
  2. How's interrupt handler?
    By lchunr in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 03-22-2003, 08:10 PM
  3. interrupt handler functions in Visual C++ 6.0
    By scromer in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 01-07-2002, 06:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21