ARM assembly language program to detect the even parity [closed]

  arm, assembly, c++

Write an ARM assembly language program to detect the even parity of the value stored in register r0 and store the result of detection in the least significant bit of register r1, i.e.

if r0 contains an even number of ones, 
         r1 = 0x00000001 
else
         r1 = 0x00000000

Do this using the following algorithm:
Initialize r1 to 0x00000001 (assume initially that we have zero number of ones – which is even) and go through the bits of r0 one by one. If this bit is 1, you complement the least significant bit of r1. Therefore, you can do this by looping for 32 iterations. In each iteration, you rotate r0 by one position and use the carry flag value to decide the complementing of the least significant bit of r1.

Source: Windows Questions C++

LEAVE A COMMENT