Upload
myles-stephens
View
217
Download
0
Embed Size (px)
DESCRIPTION
How is the base-2 or binary number represented? ECE 362 Microprocessor Systems and Interfacing ©1-3 Base-2: each digit can be either 0 or 1 weights
Citation preview
ECE 362 Microprocessor Systems and Interfacing © 5-1
Lecture 1 Hexadecimal Computation
Outline Decimal Binary Octal Hexadecimal
How is the base-10 or decimal number represented?
ECE 362 Microprocessor Systems and Interfacing © 1-2
Base-10: each digit can be 0 to 9
weights
How is the base-2 or binary number represented?
ECE 362 Microprocessor Systems and Interfacing © 1-3
Base-2: each digit can be either 0 or 1
weights
How to convert Decimal to Binary?
Above decimal point Keep dividing by 2 Remainders are binary sequence of the given
decimal Below decimal point
Keep multiplying by 2 Binary sequence of values above decimal point
ECE 362 Microprocessor Systems and Interfacing © 1-4
How is the base-16 or hexadecimal number represented?
ECE 362 Microprocessor Systems and Interfacing © 1-5
Base-16: each digit can be 0 to F
How to convert Hexadecimal to Decimal?
ECE 362 Microprocessor Systems and Interfacing © 1-6
weights
ECE 362 Microprocessor Systems and Interfacing ©
How to represent common decimal numbers in hexadecimal?
1-7
Decimal Hex25651151210231024 (1K)20472048 (2K)40954096 (4K)81918192 (8K)1638316384 (16K)3276732768 (32K)6553565536 (64K)
ECE 362 Microprocessor Systems and Interfacing ©
How to represent common decimal numbers in hexadecimal?
1-8
Decimal Hex25651151210231024 (1K)20472048 (2K)40954096 (4K)81918192 (8K)1638316384 (16K)3276732768 (32K)6553565536 (64K)
How to perform Decimal Addition?
111 3758
+ 4657 8415
What is going on?
1 1 1 (carry) 3 7 5 8 + 4 6 5 7
14 11 15- 10 10 10 (subtract the base)
8 4 1 5
How to perform Binary Addition?
Rules: 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 2 = 102 = 0 with 1 to carry
1 + 1 + 1 = 3 = 112 = 1 with 1 to carry
How to perform Binary Addition?
1 1 1 1 1 1 0 1 1 1 + 0 1 1 1 0 0 2 3 2 2 - 2 2 2 2 1 0 1 0 0 1 1
Verification 5510
+ 2810
8310
64 32 16 8 4 2 1 1 0 1 0 0 1 1 = 64 + 16 + 2 +1 = 8310
ex) Verification 1 0 0 1 1 1 + 0 1 0 1 1 0 + ___ ___________ 128 64 32 16 8 4
2 1
= =
How to perform Binary Addition?
How to perform Octal Addition?
1 1 6 4 3 78
+ 2 5 1 08 9 9 - 8 8 (subtract Base (8))
1 1 1 4 78
How to perform Octal Addition?
Ex)
3 5 3 68 + 2 4 5 78 - (subtract Base (8))
How to perform Hexadecimal Addition?
1 1 7 C 3 916 + 3 7 F 216 20 18 11 - 16 16 (subtract Base (16))
B 4 2 B16
8 A D 416
+ 5 D 616 - (subtract Base (16))
16
How to perform Hexadecimal Addition?
How to perform Decimal Subtraction?
7 13 10 8 4 1 15
- 4 6 5 7 3 7 5 8
How is it done?(add the base 10 when borrowing)
10 10 7 3 0 10
8 4 1 5 13 10 15
- 4 6 5 7 3 7 5 8
How to perform Binary Subtraction?
1 2 1
0 2 0 2 2 1 0 1 0 0 1 1 - 0 1 1 1 0 0 1 1 0 1 1 1
Verification 8310
- 2810
5510
64 32 16 8 4 2 1 1 1 0 1 1 1 = 32 + 16 + + 4 + 2 +1 = 5510
How to perform Binary Subtraction?
ex Verification 1 0 0 1 1 1 - 0 1 0 1 1 0 - ___ ___________ 128 64 32 16 8
4 2 1
= =
How to perform Octal Subtraction?
8 0 0 8 1 1 1 4 78
8 9 - 6 4 3 78
2 5 1 08
ex
3 5 3 68 - 2 4 5 78
How to perform Octal Subtraction?
How to perform Hexadecimal Subtraction?
B 16 7 C 3 916 19
- 3 7 F 216 4 4 4 716
8 A D 416
- 5 D 616 16
How to perform Hexadecimal Subtraction?
Notations to distinguish
In order to avoid misunderstanding, different prefixes and suffixes are directly added to the numbers. The prefix $ or 0x as well as the suffix h marks the numbers in hexadecimal system.
For example, hexadecimal number 10AF may look as follows $10AF, 0x10AF or 10AFh.
Similarly, binary numbers usually get the suffix % or 0b,
ECE 362 Microprocessor Systems and Interfacing © 1-24