Lab Micro-Processor, Micro-Controller and Interfacing:: Basic Part 2
Lab Micro-Processor, Micro-Controller and Interfacing:: Basic Part 2
Interfacing:
Basic part 2
Book read
Assembly language programming Ytha Yu
Chapter 2 Representation of Numbers and Characters
Prepared by:
Nasif M. (Lecturer, Dept. of CSE, UIU.)
Department of Computer Science & Engineering (CSE), United International University (UIU).
Number System
• Consists of TWO Things:
– A BASE
– A SET of DIGITS
• Digits are symbols representing all values less than the
radix value.
2
Department of Computer Science & Engineering (CSE), United International University (UIU).
Common Bases
• Binary
– Radix = (2)10
– Digit Set = {0, 1}
• Octal
– Radix = (8)10
– Digit Set = {0, 1, 2, 3, 4, 5, 6, 7}
• Hexadecimal
– Radix = (16)10
– Digit Set = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}
3
Department of Computer Science & Engineering (CSE), United International University (UIU).
Binary to Decimal
4
Department of Computer Science & Engineering (CSE), United International University (UIU).
Decimal to Binary
4215 d = 1000001110111 b
5
Department of Computer Science & Engineering (CSE), United International University (UIU).
Class Work
• Binary to Hexadecimal
• Hexadecimal to Binary
• Decimal to Hexadecimal
• Hexadecimal to Decimal
6
Department of Computer Science & Engineering (CSE), United International University (UIU).
Class Work (contd.)
7April 2015.
Department of Computer Science & Engineering (CSE), United International University (UIU).
Unsigned Integer
• An 8 bit number system can be used to create 256
combinations (from 0 to 255)
Binary value Unsigned interpretation
00000000 0
00000001 1
⋮ ⋮
01111110 126
01111111 127
10000000 128
10000001 129
10000010 130
⋮ ⋮
11111110 254
11111111 255
8
Signed Integer
• In computing, signed number representations are required
to encode negative numbers in binary number systems.
Two's complement
Binary value interpretation in decimal
00000000 0
MSB 0 means positive 00000001 1
⋮ …..
MSB 1 means negative 01111110 126
01111111 127
10000000 −128
10000001 −127
10000010 −126
⋮ …….
11111110 -2
11111111 -1
9
Two's complement Unsigned interpretation in
Binary value (8 bit) interpretation in decimal decimal
00000000 0 0
00000001 1 1
⋮ ⋮ ⋮
01111110 126 126
01111111 127 127
10000000 −128 128
10000001 −127 129
10000010 −126 130
⋮ ⋮ ⋮
11111110 −2 254
11111111 −1 255
10
11
2's complement
• To calculate the 2's complement of an integer, invert the
binary equivalent of the number by changing all of the ones
to zeroes and all of the zeroes to ones (also called 1's
complement), and then add one.
• Unsigned
Binary (1000-0000) msb value is 1 so it is negative
NOT 111-1111
+1
------------------------
1000-0000 b
128 Decimal
12
• 16 bit unsigned number range (0 to 65535)
13
Test Your Skill
April 2015.
Department of Computer Science & Engineering (CSE), United International University (UIU).