Question
I have to write an assembly language program to calculate the Hamming distance between two integers.-- So if user enters x: 3 and y: 10
I have to write an assembly language program to calculate the Hamming distance between two integers.--
So if user enters x: 3 and y: 10
x: 0011 y: 1010
the output is 2
(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.
So far I have this:
.data PromptX: .asciiz " Enter the number for x: " PromptY: .asciiz " Enter the number for y: " PromptQuit: .asciiz " To quit enter 0" PromptResult: .asciiz " Hamming Distance is: " .text main:
li $v0,4 la $a0,PromptX syscall li $v0,5 syscall move $t1,$v0 li $v0,4 la $a0,PromptY syscall li $v0,5 syscall move $t2,$v0 li $t0, 8 Loop: blt $t0, 0, EndLoop srlv $t3, $t1, $t0 and $t3, 1 srlv $t4, $t2, $t0 and $t4, 1 li $v0, 1 move $a0, $t3 li $v0, 1 move $a1, $t4 sub $t0, $t0, 1 b Loop EndLoop: li $v0, 10 syscall
So far I have this and I dont know what i should do next or change. Write it in Mips Language Thank you!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started