Forums

Differences between interrupt service routine (ISR) and a subroutine

Started by 2005 November 28, 2006
Hi

What are the differences between ISR and a subroutine in embedded
systems, how about the following:
- interrupts are disabled by the microprocessor prior to calling the
isr
- isr's are always smaller
- an isr cannot be written in C
- a subroutine always has arguments
- the CPU flags are stored on the stack in addition to the return
address

Thanks

"2005" <uws2003@yahoo.com> wrote in message 
news:1164736936.337323.40270@j44g2000cwa.googlegroups.com...
> Hi
This is another homework question isn't it?
> What are the differences between ISR and a subroutine in embedded > systems, how about the following: > - interrupts are disabled by the microprocessor prior to calling the > isr
Not always - google for nested interrupts.
> - isr's are always smaller
Not necessarily. ISRs _should_ be kept small but that doesn't always happen.
> - an isr cannot be written in C
Not true but when written in C you normally need an attribute to tell the compiler that the function is to be an ISR.
> - a subroutine always has arguments
Not true. void Subroutine(void); is a perfectly acceptable prototype.
> - the CPU flags are stored on the stack in addition to the return > address
That is true (although I suspect some pedants will find an example of systems that don't).
In article <1164736936.337323.40270@j44g2000cwa.googlegroups.com>, 
uws2003@yahoo.com says...
> Hi > > What are the differences between ISR and a subroutine in embedded > systems, how about the following: > - interrupts are disabled by the microprocessor prior to calling the > isr
Not always true.
> - isr's are always smaller
not true
> - an isr cannot be written in C
definitely just wrong
> - a subroutine always has arguments
nope
> - the CPU flags are stored on the stack in addition to the return > address
Depends on the CPU
> > Thanks
No problem
Thanks and wondering if
- difference between an isr and a subroutine is that an isr has no
arguments
is true or not?

In article <1164739817.612931.190780@l39g2000cwd.googlegroups.com>, 
uws2003@yahoo.com says...
> > Thanks and wondering if > - difference between an isr and a subroutine is that an isr has no > arguments > is true or not? >
Since you don't know what is in the resisters when the ISR is jumped to the idea of function arguments is meaningless.
Tom Lucas wrote:

> > - the CPU flags are stored on the stack in addition to the return > > address > > That is true (although I suspect some pedants will find an example of > systems that don't).
:) The ARM CPU copies the return address and the CPU flags into special registers. If you need reentrant interrupts, you need to copy them to the stack yourself.
"James Beck" <jim@reallykillersystems.com> wrote in message 
news:MPG.1fd6562aaec84d6d989d8e@newsgroups.bellsouth.net...
> In article <1164739817.612931.190780@l39g2000cwd.googlegroups.com>, > uws2003@yahoo.com says... >> >> Thanks and wondering if >> - difference between an isr and a subroutine is that an isr has no >> arguments >> is true or not? >> > Since you don't know what is in the resisters when the ISR is jumped to > the idea of function arguments is meaningless.
Well I can see some good uses for interrupts with arguments, making interrupt routines even easier to write in C. I'm sure someone has patented the idea already as it is quite obvious... Wilco
On 2006-11-28, Wilco Dijkstra <Wilco_dot_Dijkstra@ntlworld.com> wrote:

>> Since you don't know what is in the resisters when the ISR is >> jumped to the idea of function arguments is meaningless.
The unstated assumption seems to be that function arguments are passed in registers?
> Well I can see some good uses for interrupts with arguments, > making interrupt routines even easier to write in C. I'm sure > someone has patented the idea already as it is quite obvious...
Obvious but impossible (in general). The hardware designer has no way of knowing how the ISR is going to expect arguments to be passed. If varies from one language to the next, from one compiler to the next, and even from one build to the next when compiler flags are changed. -- Grant Edwards grante Yow! My life is a patio at of fun! visi.com
On 28 Nov, in article
     <1164736936.337323.40270@j44g2000cwa.googlegroups.com>
     uws2003@yahoo.com "2005" wrote:
>Hi > >What are the differences between ISR and a subroutine in embedded >systems, how about the following:
Sounds like a homework question, you want somebody else to answer for you. Hint see if you can find a difference between interupts and functions on NON embedded systems.
>- interrupts are disabled by the microprocessor prior to calling the >isr >- isr's are always smaller >- an isr cannot be written in C >- a subroutine always has arguments >- the CPU flags are stored on the stack in addition to the return >address
Well I suggest you go back and read the book again, as these appear to be badly copied from a text book. -- Paul Carpenter | paul@pcserviceselectronics.co.uk <http://www.pcserviceselectronics.co.uk/> PC Services <http://www.gnuh8.org.uk/> GNU H8 & mailing list info <http://www.badweb.org.uk/> For those web sites you hate
2005 <uws2003@yahoo.com> wrote:
> Hi > > What are the differences between ISR and a subroutine in embedded
Stick it up your ass, cheat. pete -- pete@fenelon.com "he just stuck to buying beer and pointing at other stuff"