Home    Bloggers    Messages    Resources
Tw  |  Fb  |  In  |  Rss
Max Maxfield

BCD Bites Back With a Design Challenge

Max Maxfield
Newest First   Oldest First   Threaded View
Page 1 / 2   >   >>
Joe Stanganelli
Joe Stanganelli
3/25/2012 6:10:48 AM
User Rank
Program Manager
Re: Ring, ring... Hello?
Now, now... COBOL's not so bad... so long as you overhaul it every 100 years. ;)

50%
50%
Ryszard Milewicz
Ryszard Milewicz
3/22/2012 1:54:44 PM
User Rank
Blogger
Re: Early IBM computers used BCD
It used BCD, but 6-bit (additional parity and flag bits):

http://www-03.ibm.com/ibm/history/exhibits/mainframe/mainframe_PP1620.html

50%
50%
WireMan
WireMan
3/22/2012 1:40:56 PM
User Rank
Blogger
Early IBM computers used BCD
I ran across some information a few weeks ago that noted IBM's 1620 computer from the late '50's and '60's used BCD exclusively for values. I think this computer also used BCD addresses for memory!  I started to learn programming (FORTRAN II) on a 1620 using punched cards in 1965. Good fun.

50%
50%
ewertz
ewertz
3/22/2012 5:39:26 AM
User Rank
System supervisor
Ring, ring... Hello?
It's the 1980s on the phone, and they want their COBOL back...!

0%
100%
WireMan
WireMan
3/21/2012 9:19:10 PM
User Rank
Blogger
Use the rule of 6's
I don't know if a "rule of 6's" exists, but to perform a BCD operation where the most-significant and least-significant nibbles in two bytes represent BCD values, you either add 00 (00000000), 06 (00000110), 60 (01100000), or 66 (01100110), depending on the result. You could test the nibbles to determine which value to add (binary addition) or you could use a lookup table. The table would need more than 256 bytes of memory, though, because the lookup table must include entries for carry bit = 1 and carry bit = 0 that result from the binary addition of the two bytes. I could work up a spreadsheet of the table if anyone has an interest.

100%
0%
Ryszard Milewicz
Ryszard Milewicz
3/21/2012 7:34:17 PM
User Rank
Blogger
Re: A simply question
Old calculators used BCD for calculations

http://www.jacques-laporte.org/Floating%20point.htm

BCD is convenient also for character mode LCDs and UART (for example sending debugging data to computer).

100%
0%
Didier_Juges
Didier_Juges
3/21/2012 6:57:09 PM
User Rank
Blogger
Re: A simply question
If you use 7 segments display, you will probably have to convert binary data to BCD before displaying.

Every time you deal with human input or output, you may be required to use the BCD notation.

It is probably never used for internal calculations (some old microcontrollers had a BCD mode, where you could directly add and substract 2 packed BCD numbers), but it may be a necessary intermediate step between your computation code and the user.

100%
0%
Nemos
Nemos
3/21/2012 5:35:22 PM
User Rank
System supervisor
A simply question
Why we still use BCD code ? For what for is practical to use BCD ?

50%
50%
Rich Quinnell
Rich Quinnell
3/20/2012 6:26:45 PM
User Rank
Blogger
Re: How literal?
Duane, I think that's ok (would need to "play computer" to be sure and no time today) but Max didn't say anything about us having a shift function available. Then again, he didn't talk about any carry bit, either, but that doesn't need an instruction, just a register. I'm thinking he's having us go through this exercise with his 4-bit instruction set in mind, and I don't think a shift is in the works for that.

His comment after your initial post suggests that we have the instructions needed to mask the nybbles but nothing to move the bits about.

Sigh, I think I'm getting too old for this "this is left as an exercise for the student" kind of thing.

50%
50%
duanebenson
duanebenson
3/20/2012 6:13:32 PM
User Rank
Blogger
Re: How literal?
I'm shockingly rusty at BCD math. I used to be able to do this stuff in my head.

In my original comment, I was thinking of comparing four bits to four bits, but that does cause the problem you note. Let me think out loud here for a minute.

Taking a largest case of 99 + 99: I'll still separate the nybbles, but once I've done that, I will use the full 8-bit accumulator and compare it to 8 bits 00001001.

Adding 1001 + 1001 would result in 00011010. If I compare to 00001001, I'll then recognize the need to add 00000110 resulting in 11000 (18 BCD).

I save the LSB (8) into either a register or a RAM location. Then I can shift the "carry" (without a wraparound) four bits to the right and add the two BCD MSBs to it.

00000001 + 00001001 + 00001001 to get 00010011. Again, compare to 00001001 which would lead to adding in 00000110 resulting in 00011001 (19) MSB and middle SB. Pack with the LSB for 0001 1001 1000 or 198 BCD.

Does that make more sense? Or am I still missing something?

 

 

50%
50%
Page 1 / 2   >   >>
More Blogs from Max Maxfield
Max concludes his tutorial on BCD arithmetic by explaining how to subtract negative numbers.
Max finds some interesting videos that play into speculations about the potential for robot domination.
Continuing his discussion of Binary Coded Decimal, Max looks at ways to represent negative numbers.
Turing machines are the theoretical basis of all digital computers. Here are the basics of their operation.
flash poll
MC on twitter
like us on facebook
Microcontroller Central    About Us     Contact Us     Help     Register     Twitter     Facebook     RSS