Truncated match.
PICList
Thread
'10 bit to BCD'
1995\08\21@110357
by
Ross Lyle
There has been a lot of discussion about BCD to Binary recently, but how
bout the other way. The "Embedded Control Handbook", page 5120 has a
16 bit to BCD listing but can take up to 885 clock cycles. Anything more
efficient out there? I need only a 10 bit to BCD routine (actually up to
999 ).
Ross Lyle
Camosun College
Victoria, BC
spam_OUTlyleTakeThisOuTcamosun.bc.ca
1995\08\21@184827
by
Tim Braun

> Date: Mon, 21 Aug 1995 07:45:52 0800
> From: Ross Lyle <.....LYLEKILLspam@spam@CAMADM.CAMOSUN.BC.CA>
> There has been a lot of discussion about BCD to Binary recently, but how
> bout the other way. The "Embedded Control Handbook", page 5120 has a
> 16 bit to BCD listing but can take up to 885 clock cycles. Anything more
> efficient out there? I need only a 10 bit to BCD routine (actually up to
> 999 ).
> Ross Lyle
> Victoria, BC < hey, that's where my sisters live!
Well, I did a binary to bcd routine that handled up to 512. You could
modify it to do 1024 without too much trouble, I suppose. I used the
fact that x / 100 = (x/2) / 50, much like the BCD>binary routines.
Using (x/4) / 25 to generate the hundreds digit will allow eight bit
subtractive calculation. Then you calculate (x/4 mod 25) * 4 + (x mod 4 )
and count the tens, leaving the ones. I wasn't concerned about time
of execution, a millisecond wasn't a problem for me. I was concerned
about RAM/ROM usage.
But I don't have the code handy.
Tim Braun  Voice: 2049422992 ext 228
Continental Healthcare Systems Canada  FAX: 2049423001
1900155 Carlton St  Email: timKILLspamchs.mb.ca
Winnipeg, Manitoba, Canada R3C 3H8  www: http://www.chs.mb.ca/~tim/home.html
More... (looser matching)
 Last day of these posts
 In 1995
, 1996 only
 Today
 New search...