# l1- number systems jhkj njn bhagavad gita ............................... ...

Post on 04-Jun-2018

216 views

Category:

## Documents

Embed Size (px)

TRANSCRIPT

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

1/32

Microprocessors & Interfacing

XX F241

Number systemsKCS Murt i

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

2/32

XX F241 MicroprocessorsKCS Murti

Structure

Number systems

Decimal

Binary

Hexa Decimal

Operations

BCD Codes

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

3/32

XX F241 MicroprocessorsKCS Murti

Number Systems

Decimal (0,1,2,3,4,5,6,7,8,9) Octal (0,1,2,3,4,5,6,7)

Binary (0,1)

A number anan-1a2a1a0a-1a-m expressed in base-rsystem, has coefficients multiplied by powers of r

an.rn+an-1.r

n-1+.+a2.r2+a1.r

1+a0.r0+a-1.r

-1+a-

2.r-2+a-m.r-

m

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

4/32

XX F241 MicroprocessorsKCS Murti

Convert to decimal

(B65F)16= 11X 163 + 6X 162 +5X 161 +15= (46687)10

(4021.2)5=4X 53+0 X 52+ 2X 51 +1 X 50 +2 X 51 = (511.4)10

(1010.011)2= 23 + 21+ 2-2+ 2-3= (10.375)10

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

5/32

XX F241 MicroprocessorsKCS Murti

(10 1100 0110 1011 . 1111 0010 )2= (2C6B.F2)16

(10 110 001 101 011 . 111 100 000 110)2= (26153.7460)8

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

6/32

XX F241 MicroprocessorsKCS Murti

Repeated division steps: Divide the decimal number by 2

Write the remainder after eachdivision until a quotient of zero is

obtained. The first remainder is the LSB

and the last is the MSB

Decimal to Binary

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

7/32

XX F241 MicroprocessorsKCS Murti

Decimal to binary..

10

Convert (153)10to Octal

0

5 0

41

20 1

1 0

2 1

Ans=101001

Integer ReminderConvert (41)10to binary

2 3

0 2

153

19 1

Ans=(231)8

0 1

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

8/32

XX F241 MicroprocessorsKCS Murti

0 E

227

14 3

Ans=0xE3H

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

9/32

XX F241 MicroprocessorsKCS Murti

Decimal fractions to octal

0.513 X 8= 4.104

0.104 X 8= 0.832

0.832 X 8= 6.656

0.656 X 8= 5.2480.248 X 8= 1.984

0.984 X 8= 7.872

(0.513)10= (0.406517..)8

Convert (0.513)10to octal

4 0 6 5 1 7

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

10/32

XX F241 MicroprocessorsKCS Murti

Two types namely radix and diminished radix complement Diminished Radix or (r-1)s complement : For a number N

with n digits,

it is defined as (rn-1)-N

Radix or rscomplement : For a number N with n digits, it

is defined as

(rn-1)-N+1

Complements

9s complement of 546700 is (999999-546700)=453299

9s complement of 012398 is (999999-012398)=987601

10s complement of 012398 is 987602

10s complement of 246700 is 753300

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

11/32

XX F241 MicroprocessorsKCS Murti

1s and 2s complement

1s complement of 1011000 is

2s complement of 1101011 is

0100111

10100101s complement of 0101101 is

0010101

2s complement of 0110111 is 1001001

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

12/32

XX F241 MicroprocessorsKCS Murti

Signed Binary Numbers

Signed magnitude of +7 00000111

Signed magnitude of -7 10000111

Represent +7 in 2s complement form

Place 0 in sign bit 0

Place magnitude in remaining 7 bits 00000111

Represent -7 in 2s complement form

Invert each bit including the MSB 11111000

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

13/32

XX F241 MicroprocessorsKCS Murti

Signed binary numbers

Get the magnitude of -7

Its 2s complement is 11111001

MSB is 1. So magnitude is in 2s

complement.Invert all bits including sign. 00000110

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

14/32

XX F241 MicroprocessorsKCS Murti

Range of numbers in 2s complement

Signed binary Decimal

01111111 +127

------

00000001 +100000000 Zero

11111111 -1

-------

10000001 -127

10000000 -128

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

15/32

XX F241 MicroprocessorsKCS Murti

+13 00001101

+9 00001001

+22 00100110

+13 00001101

-9 11110111

+4 000001001

Ignore carry

+9 00001001

-13 11110011

-4 11111100

-9 11110111

-13 11110011

-22 11101010

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

16/32

XX F241 MicroprocessorsKCS Murti

7A 0111

3F

1010

0011 1111

B9 1011 1001

7 A

3 F

1110 2510

B16 916

1 Carry

B16 916

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

17/32

XX F241 MicroprocessorsKCS Murti

Overflow

01110011

11010001

01000100

115 115

209 -47

68 68

Interpreted as

unsigned binary

(Incorrect)

Interpreted as

2s complement

(correct)

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

18/32

XX F241 MicroprocessorsKCS Murti

Each decimal digit is represented using 4 bits. Ex: convert 87410to BCD:

8 7 4

0100 0111 0100 = 010001110100BCD

Reverse the process to convert BCD to decimal

BCD code

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

19/32

XX F241 MicroprocessorsKCS Murti

1. Ease of conversion

2. Easy to design the logic circuit.

3. Only the 4 bit groups for the decimal digits 0 to 9 need to

be remembered.

1. BCD requires more bits

BCD code..

• 8/13/2019 L1- Number Systems jhkj njn bhagavad gita ............................... hgjbhbjhbjhbjhjbbjbkj jhj hbjh .........................................................bhagavad gita ...........................

20/32

XX F241 MicroprocessorsKCS Murti

Other binary codes

• 8/13/2019 L1- Number Systems jhkj njn

Recommended