Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

Porting inline assembly gnu function to keil

Porting inline assembly gnu function to keil

2005-04-28 by javida13

The following code came from the download area, UT050418A, by Bill 
Knigh.  Currently, I'm looking at the Keil Tools and the two
functions below will not compile.  If someone could help, I would 
appreciate it.


static inline unsigned __get_cpsr(void)
{
  unsigned long retval;
  asm volatile (" mrs  %0, cpsr" : "=r" (retval) : /* no inputs*/  );
  return retval;
}

static inline void __set_cpsr(unsigned val)
{
  asm volatile (" msr  cpsr, %0" : /* no outputs */ : "r" (val)  );
}

Re: [lpc2000] Porting inline assembly gnu function to keil

2005-04-28 by Richard Duits

This is actually one of the reasons why I am not using the keil compiler 
(yet?). The inline assembler is not as flexible as the gnu compiler. If 
someone has a good solution for these functions in the keil compiler I 
am also very interested.

Richard.



javida13 wrote:
Show quoted textHide quoted text
> The following code came from the download area, UT050418A, by Bill
> Knigh.  Currently, I'm looking at the Keil Tools and the two
> functions below will not compile.  If someone could help, I would
> appreciate it.
>
>
> static inline unsigned __get_cpsr(void)
> {
>   unsigned long retval;
>   asm volatile (" mrs  %0, cpsr" : "=r" (retval) : /* no inputs*/  );
>   return retval;
> }
>
> static inline void __set_cpsr(unsigned val)
> {
>   asm volatile (" msr  cpsr, %0" : /* no outputs */ : "r" (val)  );
> }
>
>
>
>
> ------------------------------------------------------------------------
> *Yahoo! Groups Links*
>
>     * To visit your group on the web, go to:
>       http://groups.yahoo.com/group/lpc2000/
>        
>     * 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/>.
>
>

Re: Porting inline assembly gnu function to keil

2005-04-28 by berniespam

> This is actually one of the reasons why I am not using the keil
>compiler

This looks very close to what you are trying to do:

http://www.keil.com/support/docs/2990.htm




--- In lpc2000@yahoogroups.com, Richard Duits <yahoo@r...> wrote:
> This is actually one of the reasons why I am not using the keil
compiler 
> (yet?). The inline assembler is not as flexible as the gnu compiler. If 
> someone has a good solution for these functions in the keil compiler I 
> am also very interested.
> 
> Richard.
> 
> 
> 
> javida13 wrote:
> 
> > The following code came from the download area, UT050418A, by Bill
> > Knigh.  Currently, I'm looking at the Keil Tools and the two
> > functions below will not compile.  If someone could help, I would
> > appreciate it.
> >
> >
> > static inline unsigned __get_cpsr(void)
> > {
> >   unsigned long retval;
> >   asm volatile (" mrs  %0, cpsr" : "=r" (retval) : /* no inputs*/  );
> >   return retval;
> > }
> >
> > static inline void __set_cpsr(unsigned val)
> > {
> >   asm volatile (" msr  cpsr, %0" : /* no outputs */ : "r" (val)  );
> > }
> >
> >
> >
> >
> >
------------------------------------------------------------------------
Show quoted textHide quoted text
> > *Yahoo! Groups Links*
> >
> >     * To visit your group on the web, go to:
> >       http://groups.yahoo.com/group/lpc2000/
> >        
> >     * 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/>.
> >
> >

Re: [lpc2000] Porting inline assembly gnu function to keil

2005-04-28 by Charles Manning

On Friday 29 April 2005 04:17, javida13 wrote:
> The following code came from the download area, UT050418A, by Bill
> Knigh.  Currently, I'm looking at the Keil Tools and the two
> functions below will not compile.  If someone could help, I would
> appreciate it.


Personally, I almost never write inline asembler. I try to keep C portable.

If you must have assember, write an assembler file. 

IMHO

Re: [lpc2000] Porting inline assembly gnu function to keil

2005-04-29 by Robert Adsett

At 10:49 AM 4/29/05 +1200, Charles Manning wrote:
>On Friday 29 April 2005 04:17, javida13 wrote:
> > The following code came from the download area, UT050418A, by Bill
> > Knigh.  Currently, I'm looking at the Keil Tools and the two
> > functions below will not compile.  If someone could help, I would
> > appreciate it.
>
>Personally, I almost never write inline asembler. I try to keep C portable.
>
>If you must have assember, write an assembler file.


Amen

Robert


" 'Freedom' has no meaning of itself.  There are always restrictions,   be 
they legal, genetic, or physical.  If you don't believe me, try to chew a 
radio signal. "  -- Kelvin Throop, III
http://www.aeolusdevelopment.com/

Re: [lpc2000] Porting inline assembly gnu function to keil

2005-04-29 by 42Bastian Schick

javida13 <javida13@...> schrieb am Thu, 28 Apr 2005 16:17:23 -0000:

> The following code came from the download area, UT050418A, by Bill
> Knigh.  Currently, I'm looking at the Keil Tools and the two
> functions below will not compile.  If someone could help, I would
> appreciate it.

Why bother with inline assembly for such.
Just write a short piece of assembly source.


-- 
42Bastian Schick

Re: [lpc2000] Re: Porting inline assembly gnu function to keil

2005-04-29 by 42Bastian Schick

Richard

> This looks very close to what you are trying to do:
>
> http://www.keil.com/support/docs/2990.htm


They use a SWI to change mode, if the OP's code is already in SYS or SVC 
mode
this is an overhead.

-- 
42Bastian Schick

RE: [lpc2000] Porting inline assembly gnu function to keil

2005-04-29 by Matthias Hertel

http://www.keil.com/support/man/docs/ca/ca_le_inlineasm.htm 
Show quoted textHide quoted text
-----Original Message-----
From:
sentto-11453166-7035-1114758666-matthias.hertel=web.de@....
com
[mailto:sentto-11453166-7035-1114758666-matthias.hertel=web.de@...
s.yahoo.com] On Behalf Of 42Bastian Schick
Sent: Friday, April 29, 2005 9:11 AM
To: lpc2000@yahoogroups.com
Subject: Re: [lpc2000] Porting inline assembly gnu function to keil

Charles Manning <manningc2@...> schrieb am Fri, 29 Apr 2005
10:49:50 +1200:

> If you must have assember, write an assembler file.

Copy this. :-)
--
42Bastian Schick


 
Yahoo! Groups Links

Re: Porting inline assembly gnu function to keil

2005-05-06 by peterburdine

--- In lpc2000@yahoogroups.com, "javida13" <javida13@y...> wrote:
> The following code came from the download area, UT050418A, by Bill 
> Knigh.  Currently, I'm looking at the Keil Tools and the two
> functions below will not compile.  If someone could help, I would 
> appreciate it.
> 
> 
> static inline unsigned __get_cpsr(void)
> {
>   unsigned long retval;
>   asm volatile (" mrs  %0, cpsr" : "=r" (retval) : /* no inputs*/  );
>   return retval;
> }
> 
> static inline void __set_cpsr(unsigned val)
> {
>   asm volatile (" msr  cpsr, %0" : /* no outputs */ : "r" (val)  );
> }

Sorry for the late response, I surgery and didn't check the group for
a while.  Here is the correct port.  I relies on the fact the the
compilier (hopefully) puts the first parameter in r0 and the return
value in r0.

static inline unsigned __get_cpsr(void)
{
    __asm { MRS R0, CPSR }
}

static inline void __set_cpsr(unsigned val)
{
    __asm { MSR CPSR_cxfs, R0 }
}

Or, if you don't like that you can use the keil specific instruction,
LDAV and STAV to put the CPSR value in a specific register and then
copy it to a local variable.

http://www.keil.com/discuss/docs/thread5775.htm#msg25753

--Peter

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.