Sei sulla pagina 1di 32

PHY 4301: Mikroprosesor &

Mikrokomputer
Semester 2-2017/2018

TEXT BOOK:
Singh, A. and Triebel, W.A., “The 8088
microprocessor-Programming, Interfacing,
Software, Hardware and Application”,
Prentice Hall, NY, 1989.
NUMBERING SYSTEMS

NUMBERING SYSTEMS

UNARY SYSTEM UNIVERSAL SYSTEM


UNARY NUMBERING SYSTEMS

Numbers are represented using scores/scratches:

3 MAIN PROBLEMS
1. Large Numbers
2. Negative Numbers
3. Non-Integers (9.1, 8.8 etc.)
UNARY NUMBERING SYSTEMS

Proposed solution:

NEWER PROBLEMS
1. Redundancy of representation. 15=IIIIVV or VVV OR VX ?
2. No representation for non-integers. 15.1=?
3. No representation for negative numbers. -15=?
UNIVERSAL NUMBERING SYSTEMS

Numbers are represented by ALPHA-NUMERIC symbols with the concept of


Least Significant Bit (LSB) and Most Significant Bit (MSB):

0 1 2 3 4 5 6 7 8 9 10 11 12 …
A=10 B=11 C=12 D=13 E=14 F=15

BINARY: 101101102

DECIMAL: 22010

HEXADECIMAL: A23F16

OCTAL: 76538
UNIVERSAL NUMBERING SYSTEMS

Numbers in any base can be calculated in the equivalent decimal form using
The WEIGHTED POSITIONAL NUMBER equation,

n 1
NumberDecimal   sibi  s0b0  s1b1  s2b 2  ...  sn 1b n 1
i 0

where s – symbols (0,1,2,3,4,5,6,7,8,9,A,B,C…)


b – base (Decimal, Binary, Octal, Hexadecimal, Radix-N)
UNIVERSAL NUMBERING SYSTEMS

Binary example: What is the decimal value for 11012?

Solution:
n 1
NumberDecimal   sibi  s0b0  s1b1  s2b 2  ...  sn 1b n 1
i 0

s – symbols (0 and 1)
b – base (binary=2)

(1  20) + (0  21) + (1  22) + (1  23) = 1 + 0 + 4 + 8 = 13


BINARY ARITHMETIC OPERATIONS

BINARY ADDITION

The concept of CARRY…

10011111 10011111 10011111


+ 00000000 + 00000001 + 10011111
--------------- --------------- ---------------
10011111 10100000 100111110
--------------- --------------- ---------------
[Case 1] [Case 2] [Case 3]
• result is 12 • result is 102 • result is 112
• carry is 0 • carry is 1 • carry is 1
µP and Digital System

Minuend(B) Subtrahend(A) Difference Borrow out

Rule 1 0 - 0 = 0
Rule 2 0 - 1 = 1 with a borrow of 1
Rule 3 1 - 0 = 1
Rule 4 1 - 1 = 0

To perform Rule 2 you have to borrow 1 from the next column. The weight
of the binary you borrow will be 2.
µP and Digital System

0 0-1 cannot perform, so


1 1 0 have to borrow 1 from
1 0 1 next column, and
perform subtraction. 10-
0 0 1 1=1

What is left after giving


1 to previous column
Binary Arithmetic - Binary Subtraction

2‘s-complement positive result


Binary Arithmetic - Binary Subtraction
2‘s-complement negative result
BINARY ARITHMETIC OPERATIONS

BINARY SUBSTRACTION

The concept of BORROW…

10011110 10011110 10011100


- 00000000 - 00000001 - 01011111
--------------- --------------- ---------------
10011110 10011101 00111101
--------------- --------------- ---------------
[Case 1] [Case 2] [Case 3]
• borrow is 0 • borrow is 1 • borrow is double 1
BINARY ARITHMETIC OPERATIONS

BINARY MULTIPLICATION

(i) (ii)
10 10 10 10 100
 00  01 10  10  11
-------- --------  11 --------- ----------
00 10 --------- 100 100
-------- +00 1100 --------- + 100
-------- --------- ----------
010 1100
------- ----------
[Case 1]

[Case 2]

[Case 3]
BINARY ARITHMETIC OPERATIONS

BINARY DIVISION

1 10
10 10 10 100
- 10 - 10
00 00
[Case 1] 000
[Case 2]
µP and Digital System
HEXADECIMAL NUMBERS

Has a radix of 16. It’s referred to as the Base 16 number system.


It uses the symbols 0-9, A ,B ,C ,D , E ,F.

Decimal Binary Hexadecimal Decimal Binary Hexadecimal


0 0000 0 16 10000 10
9 1001 9 17 10001 11
10 1010 A 25 11001 19
11 1011 B 26 11010 1A
12 1100 C 27 11011 1B
13 1101 D 29 11101 1D
14 1110 E 30 11110 1E
15 1111 F 31 11111 1F
µP and Digital System
Hexadecimal- to -Decimal Conversion

2 B 6 . C Hex. Number

162X2 161X B 160X 6 16-1X C Power of 16

256X 2 16X 11 1X 6 .0625X 12 Place Value

512 176 6 0.75 Decimal

= 694.7510
µP and Digital System
Decimal to Hexadecimal Conversion
µP and Digital System
Fractional Decimal to Hexadecimal Conversion
µP and Digital System

Fractional Hexadecimal to Binary Conversion

4 7. F E

0100 0111 1111 11102

Fractional Binary to Hexadecimal conversion


0001 0010 . 0110 1100

1 2 . 6 C16
µP and Digital System

Since the largest bit in hexadecimal is 15, in addition of two


hexadecimal numbers we have to follow the following rules

016 + 416 = 410 = 416


416 + A16 = 14 10 = E16
416 + C16 = 1610 > 15 Subtract 16 and carry 1 =1016
416 + 516 +C16 = 2110 > 15 Subtract 16 and carry 1 =1516
µP and Digital System

Add the following hexadecimal numbers

5 6 716 A B C16
A 0 C16 A 1 116
F 7 316 1 4 C D16
µP and Digital System

This is same as Binary and Decimal subtraction. The only


difference is when you borrow a 1 from the digit on left ,
you actually get a 16 since it is Hexadecimal

A B C16
- 9 C D16

0 E F16
µP and Digital System

The Octal number system has a base,or Radix of 8 , eight different


symbols 0,1,2,3,4,5,6,7 to represent number

Decimal to Octal Conversion

= 3108
µP and Digital System

Octal to Decimal Conversion

Binary to Octal Conversion


µP and Digital System
Octal -to-Binary Conversion

Since Octal numbers are from 0 to 7 ,to write it in binary we


can do use of 3 binary digits.
08 can be written in binary – 000
78 in binary can be written – 111

4 3 58

100 011 101

= 1000111012
UNIVERSAL NUMBERING SYSTEMS

In class exercise:

1. Calculate the decimal equivalent for the numbers below.


(a) 2038
(b) 18D16

2. Prove that 2310 is really 2310.

3. Write these decimal numbers as 8-bit 2's complement:


a) 12
b) -20
c) -128
d) 127
e) 0
UNIVERSAL NUMBERING SYSTEMS

In class exercise: Solution

1. Calculate the decimal equivalent for the numbers below.


(a) 2038=(380)+(081)+(282)=3+0+128=13110
(b) 18D16=(13160)+(8161)+(1162)=13+128+256=39710

2. Prove that 2310 is really 2310.


2310=(3100)+(2101)=3+20=2310
UNIVERSAL NUMBERING SYSTEMS

Converting from Decimal to other number bases:


METHOD 1: Weighted Positions

162 = 161 = 160 =


(i) Base 16 : 40010 = 19016 256 16 1
1 9 0

82 = 64 81 = 8 80 = 1
(ii) Base 8 : 25610 = 4008
4 0 0

22 = 4 21 = 2 20 = 1
(iii) Base 2 : 510=1012
1 0 1
UNIVERSAL NUMBERING SYSTEMS

Converting from Decimal to other number bases:


METHOD 2: Long Division
Division Quotient Remainder
(i) Base 16 : 40010 = 19016
400/16 25 0

25/16 1 9
Division Quotient Remainder
1/16 0 1
256/8 32 0
(ii) Base 8 : 25610 = 4008
32/8 4 0
Division Quotient Remainder
4/8 0 4
5/2 2 1
2/2 1 0
(iii) Base 2 : 510=1012
1/2 0 1
EXERCISE

1. Do the following addition and subtraction:


1. 100101b + 10111b
2. 100111101b + 10001111001b
3. B23CDh + 17912h
4. 11011b – 10110b
5. 10000101b -111011b
6. 5FC12h – 3ABD1h
7. F001Eh – 1FF3Fh
EXERCISE

1. Find the one’s complement of 5 = 0000000000000101, then


convert it to two’s complement.
2. Find the two’s complement of the two’s complement of 5 =
0000000000000101.
3. Do the following binary and hex subtraction by two’s
complement addition:
1. 10110100 – 10010111
2. 10001011 - 11110111

Potrebbero piacerti anche