Sei sulla pagina 1di 24

Lecture 1 Hexadecimal

Computation
Outline

Decimal

Binary

Octal

Hexadecimal

ECE 362 Microprocessor Systems and


Interfacing

5-1

How is the base-10 or decimal


number represented?

weights

Base-10: each digit can be 0 to 9


ECE 362 Microprocessor Systems and
Interfacing

1-2

How is the base-2 or binary


number represented?
Base-2: each digit can be either 0 or 1

weights

ECE 362 Microprocessor Systems and


Interfacing

1-3

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?

Base-16: each digit can be 0 to F

ECE 362 Microprocessor Systems and


Interfacing

1-5

How to convert Hexadecimal


to Decimal?

weights

ECE 362 Microprocessor Systems and


Interfacing

1-6

How to represent common decimal


numbers in hexadecimal?
Decimal
256
511
512
1023
1024 (1K)
2047
2048 (2K)
4095
4096 (4K)
8191
8192 (8K)
16383
16384 (16K)
32767
32768 (32K)
65535
65536 (64K)

ECE 362 Microprocessor Systems and


Interfacing

Hex

1-7

How to represent common decimal


numbers in hexadecimal?
Decimal
256
511
512
1023
1024 (1K)
2047
2048 (2K)
4095
4096 (4K)
8191
8192 (8K)
16383
16384 (16K)
32767
32768 (32K)
65535
65536 (64K)

ECE 362 Microprocessor Systems and


Interfacing

Hex

1-8

How to perform Decimal Addition?

111
3758
+ 4657
8415

What is going on?


111

(carry)

3758
+4657
-

14 11 15
10 10 10 (subtract the base)

8415

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?


1111
110111
+ 011100
2322
- 2222
1010011

Verification
5510
+ 2810
8310
64 32 16 8 4 2 1
1 0 1 0011
= 64 + 16 + 2 +1
= 8310

How to perform Binary Addition?


ex)

Verification

100111
+ 010110

+ ___

___________
128 64 32 16 8 4 2 1

=
=

How to perform Octal Addition?


11
6 4 3 78
+ 2 5 1 08
99
- 88
(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

How to perform Hexadecimal Addition?

8 A D 416
+
5 D 616
-

(subtract Base (16))


16

How to perform Decimal Subtraction?


How is it done?
(add the base 10 when borrowing)

7 13 10
8 4 1 15
4 6 5 7
3 7 5 8 10

10 10
7 3 0 10
8 4 1
5
15
-4 6 5
7
3 7 5 8

13

How to perform Binary Subtraction?


Verification
8310

1 21
02 022
1010011
- 011100
1 1 0 111

- 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
100111
- 010110
- ___
___________
128 64 32 16 8 4 2 1
=
=

How to perform Octal


Subtraction?
8
008
1 1 1 4 78
89
- 6 4 3 78
2 5 1 08

How to perform Octal


Subtraction?
ex

3 5 3 68
- 2 4 5 78

How to perform Hexadecimal


Subtraction?

B 16
7 C 3 916
19
3 7 F 216
4 4

4 716

How to perform Hexadecimal


Subtraction?
8 A D 416
-

5 D 616
16

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

Potrebbero piacerti anche