0% found this document useful (0 votes)
60 views45 pages

Display/: Batch: 12electronics Department of Electronics Mehran University of Engineering & Technology, Pakistan

Here are the step-by-step workings: 1) Bring down the first 4 bits of the dividend: 1000 2) Divide 1000 by 1011: 1000 1011 ) 1000 ----- 0 3) Put the quotient bit in the quotient: 0 4) Multiply the divisor by the quotient bit and subtract: 1011 x 0 = 0000 1000 - 0000 ----- 1000 5) Bring down the next bit of the dividend: 1 6) Divide 1001 by 1011: 1001 1011 ) 1001 ----- 0 7) Put the quotient bit in the quotient: 0 8) Multiply the divisor by the quotient bit and subtract: 1

Uploaded by

Old Songs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views45 pages

Display/: Batch: 12electronics Department of Electronics Mehran University of Engineering & Technology, Pakistan

Here are the step-by-step workings: 1) Bring down the first 4 bits of the dividend: 1000 2) Divide 1000 by 1011: 1000 1011 ) 1000 ----- 0 3) Put the quotient bit in the quotient: 0 4) Multiply the divisor by the quotient bit and subtract: 1011 x 0 = 0000 1000 - 0000 ----- 1000 5) Bring down the next bit of the dividend: 1 6) Divide 1001 by 1011: 1001 1011 ) 1001 ----- 0 7) Put the quotient bit in the quotient: 0 8) Multiply the divisor by the quotient bit and subtract: 1

Uploaded by

Old Songs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 45

http://electronicsproject.

org/simple-quiz-
display/ BATCH: 12ELECTRONICS
DEPARTMENT OF ELECTRONICS
MEHRAN UNIVERSITY OF ENGINEERING &
TECHNOLOGY, PAKISTAN

Subject Teacher: Kehkashan Asma


Assistant Professor
Dept of Electronics
MUET, PK
1. Binary Addition
2. Binary Subtraction
3. Binary Multiplication
4. Binary Division
5. Signed and unsigned binary numbers
6. 1s Complement
7. 2s complement
8. BCD Addition
9. Hexadecimal Addition & subtraction
What just happened?
111
1 1 1 (carry)
3758 3 7 5 8
+4 6 5 7
+ 4657 8 14 11 15 (sum)
- 10 10 10 (subtract the base)
8415 8 4 1 5

So when the sum of a column is equal to or greater than


the base, we subtract the base from the sum, record the
difference, and carry one to the next column to the left.
Rules:
 0+0 =0
 0+1 =1 (just like in decimal)
 1+0 =1

 1+1 = 210
= 102 = 0 with 1 to carry

 1+1+1 = 310
= 112 = 1 with 1 to carry
A1 B1 Cin ∑1 Cout
A0 B0 ∑0 Cout
0 0 0 0 0
0 0 0 0
0 0 1 1 0
0 1 1 0
0 1 0 1 0
1 0 1 0
0 1 1 0 1
1 1 0 1
1 0 0 1 0
•Truth table for Addition of 2 Binary bits 1 0 1 0 1
•General Form: A0+B0=∑0+Cout
1 1 0 0 1
C in C in
1 1 1 1 1
A1 A0
B1 B0 •Truth table for Addition of 3 Binary bits
+ •General Form: A1+B1+ Cin=∑1+Cout
∑2 ∑1 ∑0
+ +
C out C out
Col 1) Add 1 + 0 = 1
Example 1: Add Write 1
binary 110111 to 11100 Col 2) Add 1 + 0 = 1
Write 1
Col 3) Add 1 + 1 = 2 (10 in binary)
1 1 1 1 Write 0, carry 1
1 1 0 1 1 1 Col 4) Add 1+ 0 + 1 = 2
+ 0 1 1 1 0 0 Write 0, carry 1
Col 5) Add 1 + 1 + 1 = 3 (11 in binary)
1 0 1 0 01 1 Write 1, carry 1
Col 6) Add 1 + 1 + 0 = 2
Write 0, carry 1
Col 7) Bring down the carried 1
Write 1
You can always check your Verification
answer by converting the
figures to decimal, doing the 1101112  5510
addition, and comparing the
answers. +011100 2 + 28 10
8310
1 1 0 1 1 1
+ 0 1 1 1 0 0 1 0 1 0 0 1 12
1 01 00 1 1 = 64+0+16+0+0+2+1
= 8310
Example 2: Verification
Add 1111 to 111010. 1110102  5810
+ 0011112 +1510
1 1 1 1 1 7310
1 1 1 0 1 0
+ 0 0 1 1 1 1 64 32 16 8 4 2 1
1 0 0 1 0 0 1
1 0 0 1 0 0 1
= 64 + 8 +1
= 7310
Example7-1:

5 101 18 00010010
+2 + 011 + 2 + 00000010

7 111 20 00010100

8 1000 147 10010011


+3 + 0011 + 75 + 01001011
11 1011 222 11011110
Subtract 1) Try to subtract 5 – 7  can’t.
4657 from 8025: Must borrow 10 from next column.
Add the borrowed 10 to the original 5.
Then subtract 15 – 7 = 8.
2) Try to subtract 1 – 5  can’t.
7 9 11 Must borrow 10 from next column.
8 10 215 But next column is 0, so must go to
column after next to borrow.
- 4 6 5 7 Add the borrowed 10 to the original 0.
3 3 6 8 Now you can borrow 10 from this column.
Add the borrowed 10 to the original 1..
Then subract 11 – 5 = 6
3) Subtract 9 – 6 = 3
4) Subtract 7 – 4 = 3
 In binary, the base unit is 2

 So when you cannot subtract, you borrow from the


column to the left.
 The amount borrowed is 2.
 The 2 is added to the original column value, so
you will be able to subtract.
Rules:
 0-0 =0 borrow 0
 0-1 =1 borrow 1
 1-0 =1 borrow 0
 1–1 =0 borrow 0
A1 B1 Bin D1 Bout
A0 B0 D0 Bout
0 0 0 0 0
0 0 0 0
0 0 1 1 1
0 1 1 1
0 1 0 1 1
1 0 1 0
0 1 1 0 1
1 1 0 0
1 0 0 1 0
•Truth table for Addition of 2 Binary bits 1 0 1 0 0
•General Form: A0 - B0=D0+Bout
1 1 0 0 0
Bin Bin
1 1 1 1 1
A1 A0
B1 B0 • Truth table for Addition of 3 Binary bits
- •General Form: A 1 - B1 - Bin=D1+Bout
D2 D1 D0 • Easy way to write the truth table is to
+ + remember D = A 1 –B1 –Bin
Bout Bout And Bout = 1 if A 1 < (B1 + Bin)
Col 1) Subtract 1 – 0 = 1
Col 2) Subtract 1 – 0 = 1
Col 3) Try to subtract 0 – 1  can’t.
Example 1: Subtract Must borrow 2 from next column.
binary 11100 from 110011 But next column is 0, so must go to
column after next to borrow.
Add the borrowed 2 to the 0 on the right.
2 1 Now you can borrow from this column
(leaving 1 remaining).
0 0 2 2 Add the borrowed 2 to the original 0.
1 1 0 0 1 1 Then subtract 2 – 1 = 1
Col 4) Subtract 1 – 1 = 0
- 1 1 1 0 0 Col 5) Try to subtract 0 – 1  can’t.
Must borrow from next column.
1 0 1 1 1 Add the borrowed 2 to the remaining 0.
Then subtract 2 – 1 = 1
Col 6) Remaining leading 0 can be ignored.
Verification
Subtract binary
11100 from 110011: 1100112  5110
- 111002 - 2810
2310
1 1 0 0 1 1
- 1 1 1 0 0 64 32 16 8 4 2 1
1 0 1 1 1
1 0 1 1 1
= 16 + 4 + 2 + 1
= 2310
Verification
Example 2: Subtract
binary 10100 from 101001 1010012  4110
- 101002 - 2010
2110
0 2 0 2
1 0 1 0 0 1 64 32 16 8 4 2 1
- 1 0 1 0 0 1 0 1 0 1
1 0 1 0 1 = 16 + 4 + 1
= 2110
Example7-2:

27 00011011 172 10101100


- 10 + 00001010 - 42 - 00101010
17 00010001 130 10000010

9 1001 192 11000000


- 4 + 0100 - 3 - 00000011
5 0101 189 10111101
1 1 0 1 Multiplicand
x 0 1 1 0 Multiplier

0 0 0 0 Partial products
1 1 0 1
1 1 0
+ 0 0 1
0 0

1 0 0 1 1 1 0 Product

Since we always multiply by either 0 or 1, the partial


products are always either 0000 or the multiplicand
(1101 in this example)

There are four partial products which are added to form the
result
1 1 0 1
x 1 0 1 1
1 1 0 1 Add
1 1 0 1 Shift, then add
0 0 0 0
Shift
1 1 0 1
Shift, then add
1 0 0 0 1 1 1 1
Q: Divide 1 0 0 1 0 01 1 by 1 01 1

0 0 0 0 1 1 0 1 Quotient

Divisor 1 0 1 1 1 0 0 1 0 0 1 1 Dividend
1 0 1 1
Partial 0 0 1 1 1 0
Remainder 1 1 0 1 1
0 0 0 0 1 1 1 1
Partial
Remainder 2 1 0 1 1
1 0 0 Remainder

Quotient = 1 1 01
Remainder = 1 0 0
Multiply the number by 2.
Example: 0.812510 = (?)2
0.8125x2 =1.625 = 0.625 carry1
0.625x2 = 1.25 = 0.25 carry1
0.25x2 = 0.5 = 0.5 carry0
0.5x2 =1.0 =0 carry1
So 0.812510 = 0.11012
Example: 0.7710 = (?)2
0.77x2 =1.54 =0.54 carry1
0.54x2 =1.08 =0.08 carry1
0.08x2 =0.16 =0.16 carry0
0.16x2 =0.32 =0.32 carry0
0.32x2 =0.64 =0.64 carry0
0.64x2 =1.28 =0.28 carry1 and so on
We may stop here but the answer would be approximate.
0.7710 ≈ 0.1100012
Example: 25.62510 = (?)2

2 25 1
0.625x2 =1.25 =0.25 carry1
2 12 0
0.25x2 =0.5 =0.5 carry0
2 6 0 0.5x2 =1.0 =0.0 carry1
2 3 1 0.625 = 0.101
1

Therefore, 25.62510 = 11001.1012


25 = 11001
Example of Addition: (25.625 + 25.625)10 = (?)2
25.625 11001.101
+25.625 +11001.101
51.25010 110011.0102
Example of Subtraction:
0.8125 0.110100
- 0.77 -0.110001
0.042510 0.0000112
Example of Multiplication: (0.8125 x 0.8125) =
(?)2
0.8125 0.1101
X 0.8125 x 0.1101
40625 01101
6250x 00000x
8125xx 01101xx
65000xxx 01101xxx
00000xxxx 00000xxxx
0.101010012
0.6601562510
Example of Division: (2 ÷5) = (?)2

5 20 0.4 101 1000 0.011001


20 101
X 0110
101
001000
101
011
unsigned signed
16710 101001112 -8910

•Signed vs. unsigned is a matter of


interpretation; thus a single bit pattern can
represent two different values.
•Allowing both interpretations is useful:
Some data (e.g., count, age) can never be
negative, and having a greater range is useful.
Range of numbers in an 8 bit system is
28 = 256
It numbers are signed:
Out of 256; range of +ve numbers is
0to 127 (00000000to 01111111)
Out of 256; ranger of –ve numbers is
-1 to -128 (11111111 to 10000000)
If numbers are unsigned:
0to 255 (00000000to 11111111) will be the range of
all +ve numbers.
0to 1 & 1 to 0is called 1’s complement
1’s complement of 1110 is 0001
1’s complement of 01011010 is ?
2s Complement = 1s complement +1
Example: 10112 find its 2’s Complement.
1s complement of 1011 = 0100
Now adding 1 in it we get = 0101
The complemented method of subtraction reduces subtraction as
an addition process.
This method is popular in digital computers because only
adder circuits are needed thus simplifying the circuits & it is
easy with digital circuits to get complements.
With 2’s complement method, both +ve & -ve numbers can be
represented using the same format, and binary subtraction
is greatly simplified.
This method uses the MSB to signify whether the number is
+ve or –ve. The MSB is therefore called sign bit.
If sign bit = 0number is +ve
If sign bit = 1 number is -ve
Example: Convert +3510 to two’s complement.

2 35 1 True Binary =0010 0011


2 17 1
Two’s complement =0010 0011
2 8 0
2 4 0
2 2 0
1
Example: Convert -3510 to two’s complement

True Binary =0010 0011


One’s complement =1101 1100
Add 1 = +1
Two’s complement =1101 1101
Example: Convert 1101 1101 two’s complement
back to decimal.
The sign bit is 1, so the decimal result will be
negative.

Two’s complement =1101 1101


Complement =0010 0010
Add 1 = +1
True binary =0010 0011
Decimal Equivalent = -35
Home work:
Convert -9810 to two’s complement.
Convert 1011 0010 two’s complement to decimal.
Example: Using 2’s complement, subtract 10102
from 11012
Normal subtraction 1101
-1010
0011

2’s complement subtraction: 1010 should be


converted to its 2’s complement form I –e 0110
Now 1101
+0110
10011
Drop the extra bit, so the final answer is 00112
Example: Perform the following subtraction
using 8-bit two’s complement arithmetic.
18 –7 = ?
18 0001 0010
-7 1111 1001
Sum 00001011 = 1110

Homework: related examples and problems from


William klietz
1. Add the BCD numbers as regular true binary
numbers
2. If the sum is 9 (1001) or less, it is a valid BCD
answer, leave it as it is.
3. If the sum is >9 or if there is a carry-out of the
MSB, it is an invalid BCD number, do step4.
4. If it is invalid, add 6 (0110) to the result to
make it valid. Any carry-out of the MSB is
added to the next-more-significant BCD
number.
5. Repeat steps 1 to 4 for each group of BCD bits.
Add 965 and 672

965 - 1001 0110 0101 +


Greater than
9. 672 - 0110 0111 0010 Greater than 9.
So add 6 with So add 6 with
the nibble 1111 1101 0111 + the nibble

0110 0110
0001 0110 0011 0111  (1637)10
Example 7-17: convert decimal to BCD add them.
Convert the result back to check your answer.
a) 8+7 = ?
8 1000
+7 +0111
1510 1111 (invalid BCD)
+0110 (add 6)
1 0100 (0001 0101)BCD =1510

b) 52 + 63 = ?
c) 78 + 69 = ?
d) 123+23 = ?
e) 123 + 19 = ?
1. Add the two hex digits by working with their
decimal equivalents
2. If the decimal sum is <16, write down the hex
equivalent
3. If the decimal sum is 16 or more, write down
the hex result in that column, and carry 1 to
the next more significant column.
9 + C =?

C = 1210
+910
2110 > 1610 so 2110 –1610 = 510

1610 = 1016
+5
1516

9 + C = 15H
4F + 2D = ?
A7C5 + 2DA8 = ?
Alternative Method: convert to binary and then
add
0100 1111 4F
+0010 1101 +2D
0111 1100 7C
24 –C = ?
D7 –A8 = ?
A05C –24CA = ?

You might also like