Like Tree1Likes
  • 1 Post By SivaPeri

Returning with RETI from another function

This is a discussion on Returning with RETI from another function within the C Programming forums, part of the General Programming Boards category; Hi, I didn't know how the behavior will be if the following program executes. This has not to be executed. ...

  1. #1
    Registered User
    Join Date
    Jan 2012
    Posts
    2

    Post Returning with RETI from another function

    Hi,

    I didn't know how the behavior will be if the following program executes. This has not to be executed. But can somebody explain what will happen.

    Code:
    void ISR()
    {
    ........
    ........
    myfun();
    .......
    .......
    }
    
    void myfun()
    {
    ..........
    ..........
    RETI
    }
    on executing RETI from a function called from ISR how will be the behavior?

  2. #2
    Registered User
    Join Date
    Nov 2011
    Posts
    63
    I'm guessing RETI stands for "return from Interrupt". This is a really vague question because it depends on the type of architecture you're learning about. For instance, my school used a simplified made up computer architecture and the RETI instruction was the last instruction to be called in an interrupt handler. What it did was load the program counter/instruction pointer with an address stored in a special register and then it re-enabled interrupts. We also used it as an assembly instruction rather than a C instruction but either way, I would imagine it would load the PC with a value from a special register or memory location and then enable interrupts.

  3. #3
    Registered User
    Join Date
    Jan 2012
    Posts
    2
    I think got the answer the system will crash......when the ISR was called before PSW register, IP and other register would have been copied to system stack. when the function is called the current IP will be copied to system stack....So in this place when RETI trying to be executed PSW register, IP, and other register would be tried to pop up from system stack...so the registers will be corrupted and might crash....If ret is executed only current IP would be poped from stack...
    Salem likes this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 09-06-2011, 03:59 PM
  2. returning an array from a function and using again in function
    By shrinivasapte in forum C++ Programming
    Replies: 4
    Last Post: 07-22-2011, 11:27 AM
  3. Error: _ defined as a function returning a function?
    By Jardon in forum C Programming
    Replies: 15
    Last Post: 07-29-2009, 12:53 PM
  4. Returning pointer to function from function
    By Bargi in forum C Programming
    Replies: 7
    Last Post: 06-09-2008, 02:43 AM
  5. Recursion: base case returning 1, function returning 0
    By yougene in forum C Programming
    Replies: 5
    Last Post: 09-07-2007, 06:38 PM

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