1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

converting hexadecimal to decimal in Oshonsoft

Discussion in 'Oshonsoft' started by Transistorman, Oct 30, 2010.

  1. Transistorman

    Transistorman Member

    Joined:
    Jun 7, 2010
    Messages:
    390
    Likes:
    2
    Location:
    Indonesian
    how do i do it ?
     
  2. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,178
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    Its this subr from snippets

    'convert the bin number to packed bcd for RTC write
    'enter with temp1 holding the binary byte
    'exit with temp1 holding the packed BCD byte
    'also ascbfr1,ascbfr0 hold the ASCII value
    bin2bcd:
    tens = temp1 / 10
    units = temp1 Mod 10
    ascbfr1 = tens Or 0x30
    ascbfr0 = units Or 0x30
    tens = ShiftLeft(tens, 4)
    temp1 = tens Or units
    Return

    If you dont want the digits to be ASCII, delete the two lines 0f OR 0x30
     
  3. Transistorman

    Transistorman Member

    Joined:
    Jun 7, 2010
    Messages:
    390
    Likes:
    2
    Location:
    Indonesian
    thanks ..... :)

    also , watch my new video

    http://www.electro-tech-online.com/threads/4017-running-led.112715/#post921693
     
    Last edited: Oct 30, 2010

Share This Page