>There are many solutions, but two in particular that I would
>consider:
>
>1)
>o starting with number to be divided in 'value1'
>o Shift right, store result in 'value1' and 'value2'
>o shift right, 'value1' two more times, storing result in
>'value1'
>o subtract 'value2' from 'value1'
>o The result is the original 'value1' divided by 10
>
>This works likes this:
>rrf - divides by two, store in 'value2'
>rrf - now divided by four
>rrf - now divided by eight
>subtract 'value2' - now divided by ten
>
>Note also that the state of the carry flag after the last shift
>can be used to determne whether to round-up the result
>
>2)
>Alterately, I would consider using one of the general purpose
>division routines from the PICLIST. You should have one for
>your code library anyway. So unless you're code space is really
>tight and you don't need to do any other division, I'd use the
>general purpose routine rather than this specialized divide by
>ten approach.
>
>That's my $0.02
>
>Andrew
>
>
>
>
>________________________________________________
>Get your own "800" number
>Voicemail, fax, email, and a lot more
>
http://www.ureach.com/reg/tag
>
>
>---- On , Phil (
RemoveMEphilTakeThisOuTSPIDERWEB.COM.AU) wrote:
>
>
>
>>Hello everyone,
>>
>>I'm looking for a divide by 10 routine. The number that I want
>>
>>
>to divide is an
>
>
>>8 bit number but I will very likely need to divide 10 bit
>>
>>
>numbers by ten as
>
>
>>well.
>>
>>While playing with micro processors during the mid 70s I
>>
>>
>remember that
>
>
>>dividing by ten involved a shift right and an add instruction
>>
>>
>but I cannot
>
>
>>remember the sequence.
>>
>>A web search has revealed many 16 bit division routines but
>>
>>
>they look more
>
>
>>complex than I remember for a simple divide by 10.
>>
>>Again, can someone help?
>>
>>--
>>Regards,
>>Phil.
>>
>>--
>>
http://www.piclist.com hint: The list server can filter out
>>
>>
>subtopics
>
>
>>(like ads or off topics) for you. See
>>
>>
>
http://www.piclist.com/#topics
>
>
>>
>>
>
>--
>
http://www.piclist.com hint: The list server can filter out subtopics
>(like ads or off topics) for you. See
http://www.piclist.com/#topics
>
>
>
>
>