ASCII Values from 8-digit binary Numbers

Discussion in 'OT Technology' started by JustJeff, Dec 4, 2007.

  1. JustJeff

    JustJeff www.youtube.com/thisisjustjeff

    Joined:
    Oct 30, 2006
    Messages:
    1,651
    Likes Received:
    0
    Location:
    Long Island // Virginia Tech
    Hey all! Thought there has to be at least 1 guy doing assembly here, so I decided to ask:


    I'm trying to convert a hexadecimal 8-digit binary number (I.E. 0001 1110 = 2E)

    How would I go about making 2E = 46 from hex to ascii? I will have 3 registers to express the value, since the max an 8 digit binary number can represent is 255.

    So, I have

    0001 1110, and I need to somehow figure out how to find out that this value is 46, represent that in two different nibbles, and add them to a register that has the default value 30. However, I do not know how to discover the 4 or the 6 for the value. As well, how can i add on top of that to get a hundreds place digit, so if the value is 120, how do I get the 1?

    There has to be a systematic explanation, I just don't know how to approach it.

    Oh, I'm using a PIC16F8X microcontroller.
     
  2. skinjob

    skinjob Active Member

    Joined:
    Jan 6, 2001
    Messages:
    2,337
    Likes Received:
    0
    Location:
    Aztlán
    Divide by 10 and get the remainder. Take the quotient and repeat, etc.
     
  3. JustJeff

    JustJeff www.youtube.com/thisisjustjeff

    Joined:
    Oct 30, 2006
    Messages:
    1,651
    Likes Received:
    0
    Location:
    Long Island // Virginia Tech
    How would you go about dividing by 10 in assembly?

    I can't even get the remainder in assembly... that's not a plausible explanation
     
  4. skinjob

    skinjob Active Member

    Joined:
    Jan 6, 2001
    Messages:
    2,337
    Likes Received:
    0
    Location:
    Aztlán
    There should be instructions for division and obtaining a modulo. Probably div and mod. Go find a reference manual.
     
  5. JustJeff

    JustJeff www.youtube.com/thisisjustjeff

    Joined:
    Oct 30, 2006
    Messages:
    1,651
    Likes Received:
    0
    Location:
    Long Island // Virginia Tech
    It's a pic. I have rrf and rlf, nothing else to work with. I have sub, but I'd have to build the division operation. I'm not going to do that when it's not necessary. I only have 200 clock cycles to work with anyway.

    Don't worry though, I figured out the algorithm.
     

Share This Page