This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Switching to and from ARM/Thumb


> You should not modify the thumb bit in the psr directly. The correct way to
> switch modes is using the bx instruction, ie:

The cli() macro was just an example of how the arm() and thumb()
macros would be used. It was only modifying the cpsr to clear the
interrupt flag. The arm() and thumb() macros used bx as you suggest.

> .code 16
> thumb_to_arm:
>  .align 2
>  bx pc
>  nop

Does gas insert zero bytes for alignment? and is this a reasonable nop
instruction? gas compiles 'nop' to 46c0 nop (mov r8, r8).

> .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?

Cheers,
Shaun


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]