Question: Using MIPS 32/Mars. Write an assembly language program to calculate the Hamming distance between two integers. Read two integers, x and y, from the user.

Using MIPS 32/Mars.

Write an assembly language program to calculate the Hamming distance between two integers.

Read two integers, x and y, from the user. The Hamming distance between two integers is the number of positions at which the corresponding bits are different.

Example:

If the user enters two integers: x = 1 and y = 8, the output should be 2.

1 => 0 0 0 1 8 => 1 0 0 0

The arrows point to the two positions where the corresponding bits are different. (Hint: Use xor instruction.)

Once the result is printed, your program should ask Do you want to calculate Hamming Distance again?. If the user enters 1, loop back to the start of the program and read integers again. If the user enters 0, exit the program. See the prompts below:

Enter first number: Enter second number: Hamming Distance is: Do you want to calculate Hamming Distance again?

Test the program with the following data:

  1. 1) x: 1, y: 15 Hamming Distance: 3

  2. 2) x: 99, y: 56 Hamming Distance: 5

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!