Mixone
Mixone

Reputation: 1336

2 bit right shift of a 32 bit unsigned integer

How is one supposed to tackle the following question?

Let N1 be an unsigned integer over 32 bits. Give the assembly code allowing to realise the following operation:

A right shift of 2 bit order of N1, but ONLY of the bits in an even position as shown in the following illustration:

P.S: What I tried to do was evaluate every bit if its index was even but I'm not sure that is the right way, or how it would be written in assembly.

Upvotes: 0

Views: 219

Answers (1)

Tony Hopkinson
Tony Hopkinson

Reputation: 20320

Logic wise.

Get the even bits by anding with 55555555 Then right shift that, to give N1er2

Get the odd bits by Anding with AAAAAAAA to give N1o

The result would be N1er2 Ored with N1o

Upvotes: 1

Related Questions