Está en la página 1de 11

Binary Codes

Computers and other digital systems "work" with binary numbers.


I/P & O/P is usually done using decimal numbers, alphabetic, special
symbols.
Some way of representing alphanumeric with binary numbers is
required.
These representations are called codes.
Many codes are possible, and a few standard codes are used, such as:
ASCII
EBCDIC

-American
-Extended

Standard
Binary

Code
Coded

for

Information

Decimal

Interchange

Interchange

Code

BCD - Binary Coded Decimal. For numbers only.


Hardware and/or software is required to convert coded numbers into
binary numbers before any arithmetic operations can take place.

Alphanumeric Character codes


Character 6-bit internal code ASCII code

A
010 001
B
010 010
C
010 011
D
010 100
E
010 101
F
010 110
G 010 111
H
011 000
I
011 001
J
100 001

100
100
100
100
100
100
100
100
100
100

0001
0010
0011
0100
0101
0110
0111
1000
1001
1010

8-bit EBCDIC

1100
1100
1100
1100
1100
1100
1100
1100
1100
1101

0001
0010
0011
0100
0101
0110
0111
1000
1001
0001

12-bit card code

12.1
12.2
12.3
12.4
12.5
12.6
12.7
12.8
12.9
11.1

ASCII
7-bit
Codes

Character

ASCII Code

Character

ASCII Code

@
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
[
\
]
|
NULL
HORIZ TAB
LINE FEED
VERT TAB

1000000
1000001
1000010
1000011
1000100
1000101
1000110
1000111
1001000
1001001
1001010
1001011
1001100
1001101
1001110
1001111
1010000
1010001
1010010
1010011
1010100
1010101
1010110
1010111
1011000
1011001
1011010
1011011
1011100
1011101
1011110
0000000
0001001
0001010
0001011

FORM FEED
CARRIAGE RETURN
RUBOUT
SPACE
!
"
#
$
%
&
'
(
)
*
+
,
.
/
0
1
2
3
4
5
6
7
8
9
:
;
<
=
>
?

0001100
0001101
1111111
0100000
0100001
0100010
0100011
0100100
0100101
0100110
0100111
0101000
0101001
0101010
0101011
0101100
0101101
0101110
0101111
0110000
0110001
0110010
0110011
0110100
0110101
0110110
0110111
0111000
0111001
0111010
0111011
0111100
0111101
0111110
0111111

Binary Codes for Decimal Numbers


Decimal
digit

8421
(BCD)

6311

Excess-3

2-out-of-5

Gray

0000

0000

0011

00011

0000

0001

0001

0100

00101

0001

0010

0011

0101

00110

0011

0011

0100

0110

01001

0010

0100

0101

0111

01010

0110

0101

0111

1000

01100

1110

0110

1000

1001

10001

1010

0111

1001

1010

10010

1011

1000

1011

1011

10100

1001

1001

1100

1100

11000

1000

Weighted codes: 8421, 6311, Excess-3 Non-weighted codes: 2-out-of-5, Gray

Binary Codes for Decimal Numbers (cont.)


BCD - Convert decimal numbers to binary code, digit by digit
(at least 4 bits required). (for each decimal digit)

8421 code: 95.16

1001 0101 . 0001 0110


9
5
1
6

6311 code: 925

1100 0011 0111


By looking up the previous table

The Meaning of Data


e.g.: Consider the following 16-cell register
1100001111001001

1
10

11

12

13

0
14

15

16

If one assumes that the content of the register represents a binary


integer, the decimal number is:
5012110
1100001111001001 =
If one assumes an 8-bit EBCDIC code, the two characters are:

9096

In excess-3 code:
In BCD code:

CI

???

Meaningless, why???

The same bit configuration may be interpreted differently for different


types of elements of information. The computer must be programmed
to process this information according to the type of information
stored.

Boolean Algebra

George Boole (1815-1864) applied a set of symbols to


logical operations.
Digital electronics applies his set theory and logic to
(binary) switching networks.
Binary number system is used to represent the two
possible states of our systems.

The symbols 0 & 1 are used to represent:


True or False
word statements
Flow or No Flow
currents, fluids
Open or Closed
switches, doors, etc.
Voltage1 or Voltage2
etc.

anything with 2 states

Boolean Algebra
Deals with manipulation of Variables & Constants
Boolean Variables, such as X, Y, Z, A, B, C, etc. can have
"values" of either 0 or 1.
0 & 1 are constants & are symbols only, representing two
different states of a quantity.
i.e.

F or T
Low voltage or high voltage, usually written L or H
Flow or now flow
0V logical 0

e.g.

+5V logical 1
or

0V 1
+5V 0

+ ve
logic

- ve
logic

Basic Operations
NOT (compliment or invert)
AND
OR
Not 1 is written as:
1 or 1

Only 3

e.g.

Not :
X and Y
X or Y
1 or X

:
:
:

X or X
X Y
X + Y
1 + X

If the variables represent voltages of the I/P or O/P of a switching


network, we symbolically represent these operations by:
NOT

inversion symbol or bubble


X

If O/P is called C, we write:

X'

C = X

Boolean Operations (cont.)


AND

OR

A
B
A
B

C=A B
+

C=A+B

where values for X, A, B, C are 0 or 1 . They actually correspond to


two different voltage levels when realized electronically.

0 & 5V; -12V & 0V, etc.

e.g.
Characteristics of

if X = 0 C = 1

an Inverter

if X = 1 C = 0

Truth Table
X
C
0

Boolean Operations (cont.)

A
B

AND gate

C = A B

0
0
1
1

0
1
0
1

0
0
0
1

OR gate

C = A+ B

Logical
Multiplication

A
B
Logical
Addition

Also called Inclusive OR

También podría gustarte