use of Barrel shifter IN ARM TDMI 9

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View

i am preparing for intervew and i want the answer how Barrel shifter
can be used to optimize of C code at ARM processor.

i have learnt that Barrel shifter is :A  digital circuit that can shift
a data word by any number of bits in a single cycle. It is implemented
as a sequence of multiplexors: the output of one MUX is connected to
the input of the next MUX in a way that depends on the shift distance.
The number of multiplexors required is log2(n), where n is the
computer's register size.


Re: use of Barrel shifter IN ARM TDMI 9
Quoted text here. Click to load it

Karunesh,

In the interview, say exactly this:

"It's how the compiler uses its ARMs. See, the barrel shape
is perfect for hiding the application's private data. So the ARMs
hold up the barrel. Shifting is done up or down as needed to
improve performance."

The position will be yours for the taking.

NOTE: This is a joke. Don't do this in real life.

-Dave

--
David Ashley                http://www.xdr.com/dash
Embedded linux, device drivers, system architecture

Re: use of Barrel shifter IN ARM TDMI 9
Quoted text here. Click to load it

There are many uses:
The most basic application could be merging of multiple data bit fields
into one word.  For example, we need to put value A in upper half word
of a register and value B is lower half word, and if we know that both
values are less then 16 bits and unsigned, we can write

   C = (A << 16) + B;

It could then compiled into
   ADD    Rc, Rb, Ra, LSL #16

Only one instruction is needed for the add and the shift.

The second common usage is when accessing array.  For example, A is set
to array base address, B is array index, and the array elements are
word.  When reading an element from the array, we can then use

   LDR  Rc, [Ra, Rb, LSL #2]

Only one instruction is needed for the memory read, addition for address
and the shift by 2 (word size).

For question about ARM processors, the newsgroups
- comp.sys.arm
- comp.arch.embedded
are more suitable.

Joseph

Site Timeline