Re: 68K/68332 Assembly/Binary Problem



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

On Mar 30, 6:49 pm, Robert Redelmeier <red...@xxxxxxxxxxxxxxx> wrote:
So a calculator mostly would be working BCD arithmetic.
If yours has to work in hex & bin, it it relatively easy
to program those. And you are doing multi-word anyways.

I'm not too sure what you're saying; are you suggesting I
use BCD to represent decimal numbers?

I'm suggesting you use BCD to reprsent all numbers (when in
decimal mode), and do your calcs digit-wise in BCD. This makes
them much easier to display than converting from 64bit binary.

The decimal number number 129 is stored as 00000081h in binary
but as 00000129h in packed BCD.

When in hex/bin-mode, of course you can use binary to represent
all numbers because conversion is easy. Your only hassle
then is when the calculator is switched between modes, a relatively
infrequent occurance compared to the number of numbers displayed.

-- Robert

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.

My current train of thought is to code a number of Bin/Hex conversions
with relatively low cycle-counts.

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?

.



Relevant Pages

  • 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)
  • 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: lab help
    ... display '. ... it is best to use XOR instead of mov. ... BCD numbers are already coded in hex. ...
    (comp.lang.asm.x86)
  • Re: Newbie Tech: Hex to BCD conversion
    ... digit hex numbers, it's not enough to just convert the hex nibbles to ... their BCD equvalents if what you want is to end up with actual BCD ... Suppose you've got a two digit hex number. ... if you only convert the high nibble to it's BCD equvalent you get ...
    (comp.arch.embedded)