Re: 68K/68332 Assembly/Binary Problem



On Mar 30, 8:44 pm, Robert Redelmeier <red...@xxxxxxxxxxxxxxx> wrote:
kevi...@xxxxxxxxx wrote in part:

I probably should have mentioned this from the beginning;
the operation of the calculator is independant of a mode
function. It is possible to input a Binary number, input
an operator, input a Hex number, and request the answer of
the operation in Decimal directly. The specification also
indicates all numbers should be 64-bit; without mentioning
BCD. This would still leave a range of admittedly very high
integer values that can't be represented as 64-bit BCD.

It wouldn't be 64bit BCD, that'd never fit. You need 20 BCD
digits, or 80 bits.

In order to perform the Decimal conversions the best I can
come up with at the moment is to have a place-value table
of powers of ten and use indexing and addition algorithms
to compute the place-values during conversions. It will
take a large number of cycles but it's the best I can come
up with at the moment. Is this a valid approach do you think?

If you're dead-set on doing binary internally (do you really
think I/O mode conversions will be that frequent?) then the
fastest BCD conversion routine is likely to be a LUT on each
digit of each power of ten. 200 entries; avg 5 compares and
one branch for each digit. Possibly quicker if the upper 32
bits are zero and shortcutted.

A close second (possibly faster on some CPUs) is a short
power-of-ten LUT with successive subtractions.

-- Robert

Yea I'm pretty sure the conversions will be frequent. I just coded a
LUT generation subroutine and it took <10000 cycles up to 10^20; I
guess that bodes well enough for the conversion algorithms if I can
get them done and working.

The whole BCD thing; I'm a bit wary of trying it considering the
extension required to fit it into the specification for the
calculator; as you indicated I would need to increase the number of
words I'm dealing with yet again to cope with 64-bit decimal in BCD.

Thanks for the help though; at least it got me coding again rather
than sitting here pondering.

Now I just need to implement a sign tracker of some description...
nuts.

.



Relevant Pages

  • Re: 68K/68332 Assembly/Binary Problem
    ... If yours has to work in hex & bin, it it relatively easy ... use BCD to represent decimal numbers? ... possible to input a Binary number, input an operator, input a Hex ... My current train of thought is to code a number of Bin/Hex conversions ...
    (alt.lang.asm)
  • Re: 68K/68332 Assembly/Binary Problem
    ... integer values that can't be represented as 64-bit BCD. ... to compute the place-values during conversions. ... digit of each power of ten. ... power-of-ten LUT with successive subtractions. ...
    (alt.lang.asm)
  • Re: What about big integers in Ada 2005?
    ... > use of BCD except than to speed up conversions to ASCII, ... I replying to this part of your message separately. ... BCD, and its cousins, including packed decimal, are used widely in the ...
    (comp.lang.ada)
  • Re: Math error
    ... Kelvin Hales wrote: ... I've always understood pocket calculators to use BCD. ... I wonder if "xhpcalc" on my HP-UX workstation also uses BCD ... Does anybody know the technical details of Microsoft's Calculator ...
    (comp.soft-sys.matlab)