help"""""'''"""""

Discussion in 'Assembly Language Programming (ALP) Forum' started by bothie, Dec 6, 2006.

  1. bothie

    bothie New Member

    Joined:
    Nov 14, 2006
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    student
    Location:
    Harare,Zimbabwe
    i need assistance on writing an 8085 assembly language code that will determine how many of the bits in two given data bytes are different
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
  3. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    I take it you're looking for a Hamming Distance or something. You can get a value with a zero in each bit that is different by using XOR. If you want to deal with ones, then invert it. You can count by setting up a loop and applying an AND mask for each bit, successively, or you can use shift/rotate and count when the carry flag is set after each shift/rotate. I haven't written 8085 assember in about 15 years, so I'm not posting actual code.
     
  4. bothie

    bothie New Member

    Joined:
    Nov 14, 2006
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    student
    Location:
    Harare,Zimbabwe
    i think i got the one of using the rotate instruction and then counting the carry flag,but am a bit confused by the one of using the AND mask
     
  5. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    If you set b0 of the mask and AND it with the target, then you can tell if the target bit was set by the outcome. If it's set, increment your count. Move the bit in the mask to b1. Wash, rinse, repeat, until done.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice