0% found this document useful (0 votes)
13 views38 pages

(LE) BMMA2343 Microprocessor Technology (Lecture 02)

bab2

Uploaded by

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

(LE) BMMA2343 Microprocessor Technology (Lecture 02)

bab2

Uploaded by

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

Chapter 1b

Introduction to Digital Concepts


BMMA 2343 MICROPROCESSOR TECHNOLOGY

Norain binti Rahim


Universiti Teknikal Malaysia Melaka
[email protected]

UTeM | Excellence Through Competency


REVISIT CHAPTER 1a

UTeM | Excellence Through Competency


Chapter Overview

1. Binary Arithmetic
2. Binary Signed Number
3. Hardware Subtraction
4. Digital Codes
o Binary Coded Decimal (BCD)
o ASCII Code

UTeM | Excellence Through Competency


4 1. Binary Arithmetic

There are some operation can be perform by binary number:

a) Addition
b) Subtraction
c) Multiplication
d) Division

UTeM | Excellence Through Competency


5 (a) Binary Addition

Rules of binary addition:


0+0=0
0+1=1
1+0=1
1 + 1 = 0, (carry 1 to the next more significant bit)

12

0 0 1 0 1

+ 0 + 1 + 0 + 1

0 1 1 1 0

UTeM | Excellence Through Competency


6 (a) Binary Addition (cont)
Example 1: 000110102 + 000011002

12 12 carries

0 0 0 1 1 0 1 0 2610
+ 0 0 0 0 1 1 0 0 + 1210
0 0 1 0 0 1 1 0 3810

Example 2: 000100112 + 001111102

12 12 12 12 12 12 carries

0 0 0 1 0 0 1 1 1910
+ 0 0 1 1 1 1 1 0 6210
0 1 0 1 0 0 0 1 8110

UTeM | Excellence Through Competency


7 (b) Binary Subtraction

Rules of binary Subtraction:


0-0=0
0 - 1 = 1, (borrow 1 from the next more significant bit)
1-0=1
1-1=0

210

0 1 0 1 1

- 0 - 1 - 0 - 1

0 1 1 0

UTeM | Excellence Through Competency


8 (b) Binary Subtraction (cont)
Example 1: 001001012 - 000100012 = 000101002

0 210 borrows

0 0 1 0 0 1 0 1 3710
- 0 0 0 1 0 0 0 1 - 1710
0 0 0 1 0 1 0 0 2010

Example 2: 001100112 - 000101102 = 000111012

210 110

0 0 210 210 borrows


0 0 1 1 0 0 1 1 5110
- 0 0 0 1 0 1 1 0 2210
0 0 0 1 1 1 0 1 2910

UTeM | Excellence Through Competency


9 (c) Binary Multiplication

Rules of Binary Multiplication:

0x0=0
0x1=0
1x0=0
1 x 1 = 1, and no carry or borrow bits

0 0 1 1

x 0 x 1 x 0 x 1

0 0 0 1

UTeM | Excellence Through Competency


10 (c) Binary Multiplication (cont)
Example 1: 001010012 × 000001102 = 111101102
0 0 1 0 1 0 0 1 4110
x 0 0 0 0 0 1 1 0 x 610
0 0 0 0 0 0 0 0
0 0 1 0 1 0 0 1
+ 0 1 0 1 0 0 1
0 1 1 1 1 0 1 1 0 24610

Example 2: 000010002 × 000000112 = 000110002

0 0 0 0 1 0 0 0 2310
x 0 0 0 0 0 0 1 1 x 310
0 0 0 1 0 1 1 1
+ 0 0 0 1 0 1 1 1
0 0 1 0 0 0 1 0 1 6910

UTeM | Excellence Through Competency


11 (c) Binary Multiplication (cont)
Another method:

Binary multiplication is the same as repeated binary addition; add


the multiplicand to itself the multiplier number of times. For
example, 000010002 × 000000112 are same as 810 x 310. So, adding
000010002 three times itself are equivalent to 000010002 × 000000112.

Example 3: 000010002 × 000000112 = 000110002

1
0 0 0 0 1 0 0 0 810
0 0 0 0 1 0 0 0 810
+ 0 0 0 0 1 0 0 0 + 810
0 0 0 0 1 1 0 0 0 2410

UTeM | Excellence Through Competency


12 (d) Binary Division
Use the same procedure
as decimal division
Rules of Binary Division:
Binary division is the repeated process of subtraction,
just as in decimal division.

Example 1: Perform the following binary divisions:


(a) 1102 ÷ 112 (b) 1102 ÷ 102

UTeM | Excellence Through Competency


13 (d) Binary Division (cont)

Example 2: 001010102 ÷ 000001102 = 000001112

1 1 1
110 0 0 1 0 1 0 1 0
− 1 1 0
1 0 0 1
− 1 1 0
1 1 0
− 1 1 0
0

UTeM | Excellence Through Competency


14 (d) Binary Division (cont)

Example 3: 100001112 ÷ 000001012 = 000110112

1 1 0 1 1
101 1 0 0 0 0 1 1 1
− 1 0 1
1 1 0
− 1 0 1
1 1 1
− 1 0 1
1 0 1
− 1 0 1
0

UTeM | Excellence Through Competency


15 (d) Binary Division (cont)

Example 4: 1011.112 ÷ 112 = 11.11𝟏𝟎2

Y=A

UTeM | Excellence Through Competency


16 2. Signed Binary Number

• In decimal, we simply attach a minus sign to the front of a


number to make the number negative like -0.95310 or -3210.

• Since computers can only work with “1” and “0”, we need to
modify this approach slightly. This modification number we called
as Signed Binary Number.

• A signed binary number consists of both sign and magnitude


information as the computer can differentiate either the number
is positive or negative.

• However the most important thing for signed number; we need to


specify how many bits are in our numbers.

UTeM | Excellence Through Competency


17 2. Signed Binary Number (cont)

• There are 3 ways in which signed integer (whole) numbers can be


represented in binary form: Signed Magnitude, 1’s Complement
and 2’s Complement.

(a) Signed Magnitude


The left-most bit in a signed binary number is the sign bit, which
tell whether the number is positive or negative.
Example 1:

0 0 0 1 1 0 0 1 = +25 Sign bit Signed bit:


0 = positive
1 0 0 1 1 0 0 1 = -25 Magnitude bits 1 = negative

UTeM | Excellence Through Competency


18 (a) Signed Magnitude

Example 2:
Let's convert the decimal numbers -510 and -110 to binary using
Signed Magnitude Representation. For these example, four bits will
be enough to represent both number and sign:

First, we convert 5 and 1 to binary. 101 (5)


1 (1)
Now we add a sign bit to each one. Notice that we have 0101 (5)
padded '1' with zeros so it will have four bits.
0001 (1)
To make our binary numbers negative, we simply change 1101 (-5)
our sign bit from '0' to '1'.
1001 (-1)

Be sure that you do not mistake the number 11012 for 1310. Since we are using 4-bit signed
magnitude representation, we know the first bit is our sign and the remaining three bits are our
number.

UTeM | Excellence Through Competency


19 (b) 1’s Complement

• Representing a signed number with 1's complement is done


by changing all the bits that are 1 to 0 and all the bits that
are 0 to 1.

• Reversing the digits in this way is called complementing a


number.

Example 3:
How can we represent the number -510 in 1's complement?

First, write the positive value of the number in binary. 0101 (+5)
Next, we reverse each bit of the number so 1's become 1010 (-5)
0's and 0's become 1's

UTeM | Excellence Through Competency


20 (b) 1’s Complement

• Notice that all of the negative values begin


Decimal Binary (1’s)
with a 1. +7 0111
+6 0110
+5 0101
• Whenever we use 1's complement +4 0100
notation, the most significant bit always +3 0011
+2 0010
tells us the sign of the number. +1 0001
+0 0000
-0 1111
• The only exception to this rule is -0. In 1's -1 1110
-2 1101
complement, we have two ways of
-3 1100
representing the number zero. -4 1011
-5 1010
-6 1001
• Notice also that the values +0 to +7 are -7 1000
the same as the normal binary
Table 1 : 4-bit binary numbers
representation. Only the negative values in 1's complement notation
must be complemented.

UTeM | Excellence Through Competency


21 (c) 2’s Complement

• The method of 2’s complement arithmetic is commonly used


in computer to handle negative number.

Example 4:
How can we represent the number -510 in 2's complement?

First, we write the positive value of the number in


binary. 0101 (+5)
Next, we reverse each bit to get the 1's complement. 1010
Lastly, we add 1 to the number. 1011 (-5)

UTeM | Excellence Through Competency


22 (c) 2’s Complement

Decimal Binary (2’s)


+7 0111
+6 0110
+5 0101
+4 0100
• Comparing these values with 1’s +3 0011
complement table, that both +2 0010
representations use the most significant +1 0001
bit to represent the sign. +0 0000
-1 1111
-2 1110
-3 1101
• We also notice that we only have one way -4 1100
to represent 0 in 2's complement. -5 1011
-6 1010
-7 1001
-8 1000

Table 2 : 4-bit binary numbers


in 2's complement notation

UTeM | Excellence Through Competency


3. Decimal Magnitude for Signed Binary
24
Number
Example 1:
Determine decimal value of signed magnitude binary number
100101012.

Solutions:

-27 26 25 24 23 22 21 20
1 0 0 1 0 1 0 1

Magnitude value = 16+4+1= 21


Sign bit = 1 (negative value)
11001001(signed magnitude) = -2110

UTeM | Excellence Through Competency


Example : Decimal Magnitude for Signed
25 Number (cont)
Example 2:
Determine decimal values of the 1’s complement binary number
110010012.

Solutions:
Invert the 1’s complement binary number to get its magnitude:
001101102

-27 26 25 24 23 22 21 20
0 0 1 1 0 1 1 0

110010012 (1’s complement form) = -(32+16+4+2)


= -5410

UTeM | Excellence Through Competency


Example : Decimal Magnitude for Signed
26 Number (cont)
Example 3:
Determine decimal values of the 2’s complement binary number
110010012.

Solutions:
Subtract the 2’s complement binary number 110010012 with 12
to get its 1’s complement: 110010012 - 12 = 110010002
Invert the 1’s complement binary number to get its magnitude:
001101112
-27 26 25 24 23 22 21 20
0 0 1 1 0 1 1 1
110010012 (2’s complement form) = -(32+16+4+2+1)
= -55
UTeM | Excellence Through Competency
27 3. Hardware Subtraction

• Digital circuit do not perform subtraction but actually it is a


special case of addition using 2’s complement.

• The steps in executing this arithmetic are:


a) Convert the decimal number into 8 bits binary number
b) Perform 1’s complement by inverting subtrahend binary bit
0 to 1 and vice versa
c) Perform 2’s complement by adding 1 to the 1’s complement
subtrahend number
d) Add minuend and 2’s complement subtrahend
e) If there are overflow bit after the addition, just discard it to
obtain the final result.

UTeM | Excellence Through Competency


28 3. Hardware Subtraction (cont)
Example:
Now let's consider how we would solve our problem of subtracting
2710 from 7210 using 2's complement.

First, we need to convert both decimal number to 8-bits 01001000 (72)


binary number - 00011011 - (27)
??? + 45
Change subtrahend of 27 to 2’s complement. 00011011
To do this we change all the 1's to 0's and 0's to 1's and → 11100100 + 1
add one to the number. → 11100101

Add of 72 (minuend) and 2’s complemented of 27 01001000 (72)


(subtrahend). + 11100101 - (27)
100101101 + 45
Notice that our addition caused an overflow bit. Whenever
01001000 (72)
we have an overflow bit in 2's complement, we discard the
+ 11100101 - (27)
extra bit. This gives us a final answer of 001011012 (or
4510).
00101101 + 45

UTeM | Excellence Through Competency


29 4. Digital Codes

• Many specialized codes are used in digital systems.

• Some codes are strictly numeric, like Binary Coded Decimal


(BCD) and others are alphanumeric; that is, they are used to
represent numbers, letters, symbols and instructions.

• The codes introduced in this section are:


a) BCD code
b) ASCII code

UTeM | Excellence Through Competency


30 (a) Binary Coded Decimal (BCD)

• Binary Coded Decimal (BCD) is another way to present decimal


numbers in binary form.

• BCD is widely used and combines features of both decimal and


binary systems.

• Each digit is converted to a binary equivalent. Also known as


8421 code.

• To ease of conversion between machine and human-readable


formats.

UTeM | Excellence Through Competency


31 (a) Binary Coded Decimal (BCD)

• 4 bits are used to represent the


decimal digits. Decimal Binary
0 0000
1 0001
• The BCD value can never be greater 2
3
0010
0011
than 9. 4 0100
5 0101
6 0110
7 0111
• The bit sequences : 8 1000
9 1001
1010, 1011, 1100, 1101, 1110, and
1111 are not used. Table 1 : 4-bit binary numbers
in BCD

UTeM | Excellence Through Competency


32 (a) Binary Coded Decimal (BCD)

Example:
Now let's convert decimal number 87410 to Binary Coded Decimal
(BCD).

Solutions:
8 7 4
0100 0111 0100 = 0100 0111 0100BCD

• Each decimal digit is represented using 4 bits.


• Each 4-bits group can never be greater than 9.
• Reverse the process to convert BCD to decimal.

UTeM | Excellence Through Competency


33 (b) ASCII Code
• ASCII – American Standard Code for Information
Interchange.

• Seven bit code: 27 = 128 possible code groups

• Designed to be capable of representing the alphabet in lower


and upper-case, all the numbers, the standard punctuation
symbols and also additional control characters.

• Examples of use are to transfer information between


computer-to-computers, computers-to-printers, and
computer-to-internal storage.

UTeM | Excellence Through Competency


34 ASCII CODE

UTeM | Excellence Through Competency


35 ASCII CODE

ASCII code (control characters)

UTeM | Excellence Through Competency


36 ASCII CODE

ASCII code (graphic symbols 20h – 3Fh)

UTeM | Excellence Through Competency


37 ASCII CODE

ASCII code (graphic symbols 40h – 5Fh)


UTeM | Excellence Through Competency
38 ASCII CODE

ASCII code (graphic symbols 60h – 7Fh)

UTeM | Excellence Through Competency


39 EXERCISES

1. 10011111 + 00110001
2. 10101111 – 00101101
3. 00101110 x 00011001
4. 10010110 / 00000101
5. Represent decimal value of -75 in (a) signed magnitude (b) 1’s complement
(c) 2’s complement
6. What is the following binary value in decimal if it is (a) signed magnitude (b)
1’s complement (c) 2’s complement
7. Solve 5310 from 8210 using 2's complement
8. Convert the following 0101 0101 1001BCD to its decimal value equivalent
9. Given the text “BMMA2343”, what is equivalent ASCII value in (a) decimal (b)
binary (c) hexadecimal
UTeM | Excellence Through Competency

You might also like