Re: BX LR vs MOV PC,LR



Al Borowski <al.borowski@xxxxxxxxx> wrote:
Hi all,

I'm just starting out with the WinARM GCC toolchain for a Philips
LPC2138 microcontroller. I've hacked up one of the example projects so
it builds as follows:

==========

Assembling: crt0.S
arm-elf-gcc -c -mcpu=arm7tdmi-s -I. -x assembler-with-cpp -DROM_RUN
-Wa,-adhlns=
crt0.lst,-gdwarf-2 crt0.S -o crt0.o

Compiling C: main.c
arm-elf-gcc -c -mcpu=arm7tdmi-s -I. -gdwarf-2 -DROM_RUN -Os -Wall
-Wcast-ali
n -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls
-Wreturn-t
pe -Wshadow -Wunused -Wa,-adhlns=main.lst -I./inc -I./conf -MD -MP
-MF .dep/ma
n.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes
-Wnested-
xterns -std=gnu99 main.c -o main.o

Linking: main.elf
arm-elf-gcc -mcpu=arm7tdmi-s -I. -gdwarf-2 -DROM_RUN -Os -Wall
-Wcast-align -
Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls
-Wreturn-type
-Wshadow -Wunused -Wa,-adhlns=crt0.lst -I./inc -I./conf -MD -MP -MF
.dep/main.e
lf.d crt0.o main.o --output main.elf -nostartfiles
-Wl,-Map=main.map,--c
ref -lc -lnewlib-lpc -lm -lc -lgcc -lstdc++ -TLPC2138-ROM.ld

=================

Unless I'm missing something obvious, there is no Thumb or
Thumb-Interworking support here. So why do my functions return with BX
LR instead of MOV PC,LR? If both work, is one preferred over the
other? Are they the same speed?

They are the same size and the same speed (three clocks plus MAM
waitstates). I have seen that gcc 3.4 uses MOV PC,LR while gcc 4.0 uses BX
LR. I guess it doesn't really matter which one is used.

Karl Olsen



.



Relevant Pages

  • Gforth and gcc "progress"
    ... quite a bit of slowdown compared to 0.6.2. ... So the current CVS has the following speeds (all configured ... Nice progress by the gcc maintainers, ... mov esi, -4 ...
    (comp.lang.forth)
  • Re: Pointer arithmetics & memcpy
    ... This sound like gcc breakage to me (it optimizes away memcpy incorrectly ... mov %i0, %o0 ... to opinions held by my employer, Sun Microsystems. ...
    (comp.unix.solaris)
  • Re: HardBound and SoftBound
    ... You can also get the same surprising result on xlc on AIX. ... GCC is completely broken even with -O2: ... mov r3, #1 ... is being broken due to incorrect scheduling of "non aliasing" stores. ...
    (comp.arch)
  • Re: [git patches 1/2] warnings: attack valid cases spotted by warnings
    ... the above accurately describes a common code pattern matching code which caused gcc to emit the uninit'd-var warnings. ... According to the assembly language produced, sure it is larger -- by one MOV that is adjacent to other initializations, making it highly likely the initializations are all streamed together. ...
    (Linux-Kernel)
  • Re: compiler back-end development?
    ... (bug fixing for a start), I would very much like to join in. ... GCC always want help: ... mov, rcx ...
    (comp.compilers)