Switching to and from ARM/Thumb

Paul Brook paul@codesourcery.com
Tue Jan 18 01:58:00 GMT 2005


On Tuesday 18 January 2005 01:45, Daniel Jacobowitz wrote:
> > > .code32
> > > arm_to_thumb:
> > > #ifdef __ARMv4T__
> > >  add ip, pc, #1
> > >  bx ip
> > > #else
> > >  sub pc, pc, #1
> > > #endif
> > > thumb_code:
> >
> > If this is used in inline assembler, does gcc need to be informed of
> > ip being trashed?
>
> Definitely.  I admit I've never seen the arm-to-thumb sequence done
> quite that way before... I knew loads interworked and mov didn't so I
> would have assumed that sub didn't either.

Whoops, I missed that.  After rereading the relevant documentation I concur 
that "sub pc, pc, #1" will not have the desired effect.

Paul



More information about the Binutils mailing list