Professional Documents
Culture Documents
1
Binary Codes
2
The 8421 BCD
BCD stands for Binary-Coded Decimal.
BCD 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
Note: 1010, 1011, 1100, 1101, 1110, and 1111 are INVALID CODE!
BCD
Example:
Example:
Decimal Number 8 7 1
BCD
People understand decimal system better
BCD makes it easy to replace a decimal
number with an individual binary code
Decimal 15 is BCD 0001 010; in Binary it was
1111
Since most computers store data in eight-bit
bytes
◦ One can store two digits per byte, called "packed" BCD
BCD Addition
BCD is a numerical code and can be used in arithmetic
operations. Here is how to add two BCD numbers:
1.
1. Add
Addthe
thetwo
twoBCD
BCDnumbers,
numbers,using
usingthe
therules
rulesfor
forbasic
basicbinary
binary
addition.
addition.
2.
2. IfIfaa4-bit
4-bitsum
sumisisequal
equalto
toor
orless
lessthan
than9,
9,ititisisaavalid
validBCD
BCD
number.
number.
3.
3. IfIfaa4-bit
4-bitsum
sum>>9, 9,or
orififaacarry
carryout
outofofthe
the4-bit
4-bitgroup
groupisis
generated
generatedititisisananinvalid
invalidresult.
result.Add
Add66(0110)
(0110)to
toaa4-bit
4-bitsum
sum
in
inorder
orderto
toskip
skipthe
thesix
sixthe
theinvalid
invalidstates
statesand
andreturn
returnthe
the
code
codeto to8421.
8421.IfIfaacarry
carryresults
resultswhen
when66isisadded,
added,simply
simplyaddadd
the
thecarry
carryto
tothe
thenext
next4-bit
4-bitgroup.
group.
BCD Addition - Examples
4+5 0 1 0 0
+ 0 1 0 1
1 0 0 1
4+8 0 1 0 0
+ 1 0 0 0
1 1 0 0 Sum is greater than 1001
+ 0 1 1 0 Add 0110
1 0 0 1 0
12
BCD Addition - Examples
184+576
1 1
0 0 0 1 1 0 0 0 0 1 0 0 184
+ 0 1 0 1 0 1 1 1 0 1 1 0 576
0 1 1 1 1 0 0 0 0 1 0 1 0
0 1 1 0 + 0 1 1 0
0 1 1 1 0 1 1 0 0 0 0 0 760
The Excess-3 Code
Information Interchange
7 Bits to store 128 characters
In ASCII, every letter, number, and
Two
Twoorormore
moreinput
inputbits
bitsproduce
produceone oneoutput
outputbit.
bit.
Both
Bothinputs
inputsmust
mustbebetrue
true(1)(1)for
forthe
theoutput
outputto
tobe
betrue.
true.
Otherwise
Otherwisethe
theoutput
outputisisfalse
false(0).
(0).
The OR Operation
The
Thecircuit
circuit
represents
representsOR OR
operation
operationandandis
is
called
calledORORgate
gate
Two
Twoorormore
moreinput
inputbits
bitsproduce
produceoneoneoutput
outputbit.
bit.
Either
Eitherinputs
inputsmust
mustbe
betrue
true(1)
(1)for
forthe
theoutput
outputto
tobebetrue.
true.
The NOT Operation - Inverter
The
Thecircuit
circuit
represents
representsNOTNOT
operation
operationandandisis
called
calledNOT
NOTgate
gateor or
INVERTER
INVERTER
One
Onebit
bitas
asinput
inputproduces
producesits
itsopposite
oppositeas
asoutput.
output.
Truth Tables of Logic Operations
Representation of
Binary variables
Different Digital Systems
represent 0 and 1 differently
◦ Logical 0 as 0 volts. Logical 1 as
4 volts
◦ Range
Binary Logic Functions
Binary Storage and Registers