(LE) BMMA2343 Microprocessor Technology (Lecture 02)
(LE) BMMA2343 Microprocessor Technology (Lecture 02)
1. Binary Arithmetic
2. Binary Signed Number
3. Hardware Subtraction
4. Digital Codes
o Binary Coded Decimal (BCD)
o ASCII Code
a) Addition
b) Subtraction
c) Multiplication
d) Division
12
0 0 1 0 1
+ 0 + 1 + 0 + 1
0 1 1 1 0
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
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
210
0 1 0 1 1
- 0 - 1 - 0 - 1
0 1 1 0
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
210 110
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
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
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
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
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
Y=A
• 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.
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:
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.
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
Example 4:
How can we represent the number -510 in 2's complement?
Solutions:
-27 26 25 24 23 22 21 20
1 0 0 1 0 1 0 1
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
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
Example:
Now let's convert decimal number 87410 to Binary Coded Decimal
(BCD).
Solutions:
8 7 4
0100 0111 0100 = 0100 0111 0100BCD
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