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

Z80 Hex To Decimal

Discussion in 'Microcontrollers' started by fmichiels, Apr 3, 2007.

  1. fmichiels

    fmichiels New Member

    Joined:
    Apr 3, 2007
    Messages:
    1
    Likes:
    0
    Location:
    Antwerp
    I am searching a routine to convert fast 4 bytes hexadimal number into 8 bytes BCD for Z80195 assembler
     
  2. Papabravo

    Papabravo Well-Known Member

    Joined:
    Mar 9, 2006
    Messages:
    2,889
    Likes:
    25
    Location:
    Michigan, USA (GMT-5)
    Starting with 16 by 16 divide:

    What you need is an integer divide routine that returns the quotient and the remainder. The most significant digit is obtained by dividing the original number by 10,000 This digit will be the first of five digits in the result. Divide the remainder by 1000. The quotient will be the forth digit of the reult. Divide the remainder by 100. The quotient will be the third digit of the result. Divide the remainder by 10. The quotient will be the forth digit of the result and the remainder will be the fifth digit of the result. You cannot get more than five digits from a 16 bit quantity.

    Now your problem a 32 by 32 bit divide

    Same idea except now the progression of descending powers of ten starts with a larger value.
     
    Last edited: Apr 3, 2007
  3. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi fm,

    Do you want to unpack 4 hex digits into 8 BCD ?

    Are the hex digits already 'packed' BCD, as high and low nibbles?
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK

    hi fm,
    Reply your PM.

    I have searched my old Z80 library subr's and books and I cannot find one that I could say is fast, in fact they are slow division subr's.

    Also I did a web search, without success in finding a fast subr.

    If you do locate a suitable subr, let me know, I would like to have it in my Z80 library.

    Regards
     

Share This Page