Thread: Converting an int to an address in an array

  1. #16
    Registered User
    Join Date
    Mar 2009
    Quote Originally Posted by vart View Post
    so the 'n' should be outputed as 0x32?

    or your input is limited to digits?

    also - the result should be string or array of integer values? What will be sent to display registers?
    Yes, exactly. Just an array of hex values sent to the display register.
    To output 51 to the screen I would write 0x05 (the number 5) to DISPLAY_DATA_IN,
    then 0x00 (for example) for the character position register. To get the remaining 1 value I would write 0x01 to DISPLAY_DATA_IN then 0x01 to the character position register.

    Eventually I may want to do this for all characters on the table, but we definitely need to interpret integers in the mean time.

  2. #17
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    so you need ints...

    for chars '0' - '9'

    int x = ch - '0';

    will give 0 - 9 (or 0x00 - 0x 09 which is the same for integers)

    then if(x == 0) x += 10; (or x += 0x0A; if you prefer hex notation)

    and then sent x to register - do it for each digit...

    when you'll want to process more chars - do a convertion table that will contain values like

    table['n'] == 0x32;

    table size will be 255 - you you do not need to search on it - just direct access using char value as index
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

    By geoffr0 in forum C Programming
    Replies: 4
    Last Post: 04-16-2009, 05:26 PM
  2. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 12:13 AM
  3. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 05:20 AM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM