Pages created and updated by
Terry Sturtevant
Date Posted:
May 12, 2017

**Binary Coded Decimal (BCD) Arithmetic**

- decimal numbers are coded in binary
- for PIC, arithmetic operations assume packed BCD with 2 decimal digits per 8 bits

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.

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

If you need to update a browser, you might try

- free
- open source
- available for several platforms

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

- free
- open source
- available for several platforms

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

Wilfrid Laurier University

© 2015 Wilfrid Laurier University