Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8133671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:41:22+00:00 2026-06-06T09:41:22+00:00

I am new at using MIPS and I try to calculate Hamming distance. However

  • 0

I am new at using MIPS and I try to calculate Hamming distance. However even the register $t3 has the correct XOR result, when I print it in decimal I get a wrong number.

word1:      .word 0xffeff0ff
word2:      .word 0x00000001

when I XOR these two words, the result is:

ffeff0fe

my question is how do I calculate it in decimal ?
Because I tried to print it in screen and I got -1052418 instead of the correct 26

Here is my complete code

    .text       
        .globl __start 
__start:            
    la $a1,word1
    lw $t1,0($a1)       
    la $a1,word2
    lw $t2,0($a1)       
    xor $t3,$t1,$t2
    la $a0,answer       
    li $v0,4
    syscall         
    move $a0,$t3        
    li $v0,1
    syscall
    la $a0,endl     
    li $v0,4
    syscall         
EXIT:   li $v0,10
    syscall         

    .data
word1:      .word 0xffeff0ff
word2:      .word 0x00000001
answer:     .asciiz "Hamming distance is : "
endl:       .asciiz "\n"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:41:23+00:00Added an answer on June 6, 2026 at 9:41 am

    You are printing the xor of the two values instead of the number of bits which have different value. what you need to do to compute the hamming distance is to count that number, for example with this code:

        move $a0, $zero    # $a0 will hold the result
    loop:
        bgez $t3, skip     # test the most significative bit of $t3
        sll $t3, $t3, 1    # (*) [NOTE below] shift left $t3 one bit
        addiu $a0, $a0, 1  # If bit was set, increment result
    skip:    
        bnez $t3, loop     # loop while not done
        nop                # this nop is due to delayed branching
    

    This snippet assumes that your MIPS processor has delayed branching. If it is not the case, you have to move instruction marked with (*) after label skip. The nop can be removed if you don’t have delayed branching or if the next instruction does not have side effects.

    This code should go instead of the line where you put move $a0,$t3

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the NetBeans IDE. When I try to look at the
New to using JDBC and I was wondering if all operations produce a result
I implement a new module using shared_ptr etc. in our legacy app, however I
New at using admob within Android. Is it possible to show ads with certain
when using new Date,I get something like follows: Fri May 29 2009 22:39:02 GMT+0800
I'm using new style classes in Python 2.6 and am having trouble with __getattr__
Very new to using Raphael.js I'm looking at the tutorials and I am able
I am new to using jquery and would like to know how to append
I'm new in using boost and have a problem. I need shared_mutex function in
I'm new to using XPath so I've been fooling around with an XPath Evaluator

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.