Pages created and updated by Terry Sturtevant Date Posted: November 13, 2013

CP316: Microprocessor Systems and Interfacing

Decimal Arithmetic

Binary Coded Decimal (BCD) Arithmetic

e.g.   decimal 1,985 = h'19 85' in packed BCD
                              = 0001 1001 1000 0101 (in binary)

e.g. 19 85      0001 1001 1000 0101
    +34 59      0011 0100 0101 1001
      ------       ------------------------
      54 44      0100 1101 1101 1110   >> the binary sum does not give the decimal result expected
                            0110 0110 0110   >> if a digit is >9 then add 6
                     ------------------------
                    0101 0100 0100 0100   >> result is now in binary coded decimal

In the PIC, use add/addc followed with decimal adjust, daw/dawc.

Creative Commons License

Information on this site which is produced by Terry Sturtevant is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 Canada License.

Resources

To view pdf documents, you can download Adobe Acrobat Reader .
get Acrobat Reader
If you need to update a browser, you might try Firefox which is Get Firefox!
Since this page uses cascading style sheets for its layout, it will look best with a browser which supports the specifications as fully as possible.

If you are looking for an office package, with a word processor, spreadsheet, etc., you might try LibreOffice which is Get LibreOffice!

Go to the main page for the Department of Physics and Computer Science.

Valid XHTML 1.1

Valid CSS!

WCAG
2.0
(Level AA)

Wilfrid Laurier University