Xjag,
If you're looking for possible stack overrun, have you tried
initialising the stack area to a particular value (e.g. 0xdead)? By
looking at memory you can determine easily if it has been
overrunning. This is a useful technique for determining how much
stack space is actually required on a given system: you can
overdimension at the start, look at how much is actually used and re-
dimension accordingly (leaving some safety margin in).
Our standard start-up code writes different values to each of the
three stacks (supervisor, IRQ and FIQ stacks), as an aid to
debugging. I'll dig this code out if it helps.
Brendan
--- In lpc2000@yahoogroups.com, "xjag74" <detlef.weidner@w...> wrote:
> Now I realized that the interrupts use another stack (IRQ stack)
than
> a normal routine (User stack).
>
> Is it possible to read the User stack pointer within the ISR?
>
> What I try to do is to capture the SP every timer1 ISR entry
(200us)
> and to store the maximum value to figure out if the stack collides
> with the data area.
>
> The stack check option of the GNU compiler is not working.
>
> Regards
> xjag
>
>
>
>
> --- In lpc2000@yahoogroups.com, "xjag74" <detlef.weidner@w...>
wrote:
> > Thank you, that's it!
> > For GCC you have to type:
> >
> > static inline unsigned StackPointerValue(void)
> > {
> > register unsigned long stackptr asm("sp");
> > return stackptr;
> > }
> >
> > Regards
> > xjag
> >
> >
> > --- In lpc2000@yahoogroups.com, "Bill Knight" <BillK@t...> wrote:
> > > yes, I blew it. Didn't check the docs and had my head on a
> totally
> > > different project. Saw the correct answer shortly after
posting
> > mine.
> > >
> > > -Bill
> > >
> > >
> > > On Mon, 11 Jul 2005 19:22:53 +0200, Richard Duits wrote:
> > >
> > > >Copying one register to another is done with the "mov"
> instruction:
> > >
> > > >unsigned long retval;
> > > >asm volatile ("mov sp, %0" : "=r" (retval) : /* no inputs */ );
> > > >return retval;
> > >
> > > >An alternative in this case would be:
> > >
> > > >unsigned long stackptr __asm("sp");
> > > >return stackptr;
> > >
> > > >Regards,
> > > >Richard Duits
> > >
> > >
> > > >Bill Knight wrote:
> > >
> > > >> On Mon, 11 Jul 2005 15:00:32 -0000, xjag74 wrote:
> > > >>
> > > >> >Hi,
> > > >>
> > > >> >I wonder why GCC don't compile that simple code:
> > > >>
> > > >> >static inline unsigned StackPointerValue(void)
> > > >> >{
> > > >> > unsigned long val;
> > > >> > asm volatile (" str R13, retval");
> > > >> > return val;
> > > >> >}
> > > >>
> > > >> >When I try to compile the following error appears:
> > > >> >"Internal_relocation (type: OFFSET_IMM) not fixed up"
> > > >>
> > > >> >What does that mean? How can I get that running?
> > > >>
> > > >>
> > > >> 1st, 'retval' is not 'val'
> >
> > yes, I know it was late ;-)
> >
> > > >>
> > > >> I haven't compiled this but try
> > > >>
> > > >> static inline unsigned StackPointerValue(void)
> > > >>
> > > >> unsigned long retval;
> > > >> asm volatile (" str sp, %0" : "=r" (retval) : /* no inputs
> */ );
> > > >> return retval;
> > > >>
> > > >>
> > > >> Regards
> > > >> -Bill Knight
> > > >> R O SoftWare &
> > > >> http://www.theARMPatch.com
> > > >>
> > > >>
> > > >>
> > > >>
> > > >> -------------------------------------------------------------
--
> --
> > -------
> > > >> YAHOO! GROUPS LINKS
> > > >>
> > > >> * Visit your group "lpc2000
> > > >> <http://groups.yahoo.com/group/lpc2000>" on the web.
> > > >>
> > > >> * To unsubscribe from this group, send an email to:
> > > >> lpc2000-unsubscribe@yahoogroups.com
> > > >> <mailto:lpc2000-unsubscribe@yahoogroups.com?
> > subject=Unsubscribe>
> > > >>
> > > >> * Your use of Yahoo! Groups is subject to the Yahoo!
> Terms
> > of
> > > >> Service <http://docs.yahoo.com/info/terms/>.
> > > >>
> > > >>
> > > >> -------------------------------------------------------------
--
> --
> > -------
> > > >>
> > >
> > >
> > >
> > > >
> > > >Yahoo! Groups Links
> > >
> > >
> > >
> > > >Message
Re: GNU inline assembler return value
2005-07-12 by brendanmurphy37
Attachments
- No local attachments were found for this message.