Re: 68K/68332 Assembly/Binary Problem



kevinor@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


.



Relevant Pages

  • Re: How to hande SAP BCD numrics in RPGLE
    ... program that connects to a remote Unix SAP server to retrieve cost ... BCD data is just like packed except that there is no sign. ... last digit is the next to last digit, ... the zero digit), you will then have the actual number. ...
    (comp.sys.ibm.as400.misc)
  • Re: Date from Number of Days
    ... My understanding of BCD is that each hex digit is its decimal ... A byte that contains &H83 is bcd for 83 decimal. ... Could that be the reason for the Hex values being so far off? ... >> james, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: 8086 ALP TO CONVERT BCD -HEXA DECIMAL
    ... Maybe I'm following the wrong links, but I don't see any bcd code, except entwined with floating-point code... ... We want to multiply the "result so far" by ten, and add each digit as we process it. ... digit per byte - and "packed bcd" - one digit per nibble. ... or "mov ax, 0", if you must ...
    (comp.lang.asm.x86)
  • Re: Converting decimal to BCD (binary coded decimal)...
    ... > Is there a handy way to convert a decimal value to it's equivalent BCD ... > representation in VB?? ... Hi John, ... Since one byte represents 2 digits, the following works on a 2 digit number ...
    (microsoft.public.vb.general.discussion)
  • Re: 68K/68332 Assembly/Binary Problem
    ... the operation of the calculator is independant of a mode ... integer values that can't be represented as 64-bit BCD. ... to compute the place-values during conversions. ... power-of-ten LUT with successive subtractions. ...
    (alt.lang.asm)