ECE 470 Midterm: ECE470 Oakland Solutions Homework 1

33 views5 pages
ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY
ECE-470/570: Microprocessor-Based System Design Fall 2014
1 Instructor: Daniel Llamocca
Solutions - Homework 1
(Due date: September 25th @ 5:30 pm)
Presentation and clarity are very important! Show your procedure!
PROBLEM 1 (15 PTS)
Complete the following table. We are representing positive integer numbers.
Decimal
BCD (bits)
Binary
Hexadecimal
766
0111 0110 0110
1011111110
2FE
395
0011 1001 0101
110001011
18B
172
0001 0111 0010
10101100
AC
249
0010 0100 1001
11111001
F9
Complete the following table. Use the fewest number of bits in each case:
REPRESENTATION
Decimal
Sign-and-magnitude
1's complement
2's complement
-247
111110111
100001000
100001001
-51
1110011
1001100
1001101
-111
11101111
10010000
10010001
-180
110110100
101001011
101001100
101
01100101
01100101
01100101
55
0110111
0110111
0110111
PROBLEM 2 (20 PTS)
Perform the following additions and subtractions of 8-bit unsigned integers. Indicate every carry (or borrow) from c0 to c8
(or b0 to b8). For the addition, determine whether there is an overflow. For the subtraction, determine whether we need
to keep borrowing from a higher byte.
Example:
54 + 210
129 + 103
198 + 67
54 = 0x36 = 0 0 1 1 0 1 1 0 +
210 = 0xD2 = 1 1 0 1 0 0 1 0
10 0 0 0 1 0 0 0
c8=1
c7=1
c6=1
c5=1
c4=0
c3=1
c2=1
c1=0
c0=0
77 = 0x4D = 0 1 0 0 1 1 0 1 -
194 = 0xC2 = 1 1 0 0 0 0 1 0
0 0 0 0 1 0 1 1
b8=1
b7=0
b6=0
b5=0
b4=0
b3=0
b2=1
b1=0
b0=0
Overflow!
Borrow out!
129 = 0x81 = 1 0 0 0 0 0 0 1 +
103 = 0x67 = 0 1 1 0 0 1 1 1
232 = 0xE8 = 1 1 1 0 1 0 0 0
c8=0
c7=0
c6=0
c5=0
c4=0
c3=1
c2=1
c1=1
c0=0
Overflow!
No Overflow
198 = 0xC6 = 1 1 0 0 0 1 1 0 +
67 = 0x43 = 0 1 0 0 0 0 1 1
0x09 = 0 0 0 0 1 0 0 1
c8=1
c7=1
c6=0
c5=0
c4=0
c3=1
c2=1
c1=0
c0=0
43 = 0x2B = 0 0 1 0 1 0 1 1 -
98 = 0x62 = 0 1 1 0 0 0 1 0
0xC9 =1 1 0 0 1 0 0 1
b8=1
b7=1
b6=0
b5=0
b4=0
b3=0
b2=0
b1=0
b0=0
No Borrow Out
Borrow out!
149 = 0x95 = 1 0 0 1 0 1 0 1 -
87 = 0x57 = 0 1 0 1 0 1 1 1
62 = 0x3E = 0 0 1 1 1 1 1 0
b8=0
b7=1
b6=1
b5=1
b4=1
b3=1
b2=1
b1=0
b0=0
Unlock document

This preview shows pages 1-2 of the document.
Unlock all 5 pages and 3 million more documents.

Already have an account? Log in
ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY
ECE-470/570: Microprocessor-Based System Design Fall 2014
2 Instructor: Daniel Llamocca
Perform the following operations by representing the numbers in 2’s complement representation using 8 bits. Indicate
every carry (from c0 to c8). Determine whether the operation results in an overflow.
101 + 23
98 62
All of the addition/subtraction operations in 2’s complement arithmetic, regardless of whether the operands are positive or
negative, can be expressed as an addition:
98 62 = 98 + (-62) -90-82 = -90 + (-82)
The first step is to represent the positive numbers using the 2’s complement representation with 8 bits. This is a
straightforward process: we take the unsigned number representation and attach a zero to the left.
The second step is to represent the negative numbers in 2’s complement representation with 8 bits. To this end, we first
obtain the 2’s complement representation of the positive numbers. Then, we apply the 2’s complement operation to get
the 2’s complement representation of the negative numbers:
62 = 0x3E = 00111110 -62 = 0xC2 = 11000010
90 = 0x5A = 01011010 -90 = 0xA6 = 10100110
82 = 0x52 = 01010010 -82 = 0xAE = 10101110
Now, we are ready for the addition operations. This is a very simple step. The only difference is that the overflow is
specified by c8c7 (for 8 bits):
BCD Addition: We want to add these two decimal numbers using normal binary addition:
6289 + 3098 = 9387
- Convert the summation operands to their BCD representation.
- Add the binary numbers as if they were unsigned numbers.
- Specify which binary number we need to add to the previous summation so that we get the answer we are looking for
(9387).
The idea here is to implement BCD addition using standard binary summation. So, we first add the BCD numbers using
normal summation. Then, we “adjust” in order to get the proper BCD result. The “adjust” consists on adding a 0x6 to
every nibble position where the summation resulted in a number larger than 9.
In the ”6289 + 3098 = 9387” case, we found that the sum of two nibbles in the two least significant nibbles of the
summation is larger than 9. Thus, we need to add the number 0x0066 to the whole summation.
101 = 0x65 = 0 1 1 0 0 1 0 1 +
23 = 0x17 = 0 0 0 1 0 1 1 1
232 = 0x7C = 0 1 1 1 1 1 0 0
c8=0
c7=0
c6=0
c5=0
c4=0
c3=1
c2=1
c1=1
c0=0
c8c7=0
No Overflow
98 = 0x62 = 0 1 1 0 0 0 1 0 +
-62 = 0xC2 = 1 1 0 0 0 0 1 0
36 = 0x24 = 0 0 1 0 0 1 0 0
c8=1
c7=1
c6=0
c5=0
c4=0
c3=0
c2=1
c1=0
c0=0
c8c7=0
No Overflow
-90 = 0xA6 = 1 0 1 0 0 1 1 0 +
-82 = 0xAE = 1 0 1 0 1 1 1 0
0x54 = 0 1 0 1 0 1 0 0
c8=1
c7=0
c6=1
c5=0
c4=1
c3=1
c2=1
c1=0
c0=0
c8c7=1
Overflow!
0x 9 3 2 1 +
0x 0 0 6 6
0x 9 3 8 7
0x 6 2 8 9 +
0x 3 0 9 8
c4=0
c3=0
c2=1
c1=1
c0=0
1 0 0 1 0 0 1 1 0 0 1 0 0 0 0 1 +
0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0
1 0 0 1 0 0 1 1 1 0 0 0 0 1 1 1
0 1 1 0 0 0 1 0 1 0 0 0 1 0 0 1 +
0 0 1 1 0 0 0 0 1 0 0 1 1 0 0 0
c16=0
c15=1
c14=1
c13=0
c12=0
c11=1
c10=1
c9=0
c8=0
c7=1
c6=1
c5=0
c4=0
c3=0
c2=1
c1=1
c0=0
Unlock document

This preview shows pages 1-2 of the document.
Unlock all 5 pages and 3 million more documents.

Already have an account? Log in

Document Summary

Solutions - homework 1 (due date: september 25th @ 5:30 pm) Use the fewest number of bits in each case: Perform the following additions and subtractions of 8-bit unsigned integers. Indicate every carry (or borrow) from c0 to c8 (or b0 to b8). For the addition, determine whether there is an overflow. For the subtraction, determine whether we need to keep borrowing from a higher byte. 149 = 0x95 = 1 0 0 1 0 1 0 1 - Perform the following operations by representing the numbers in 2"s complement representation using 8 bits. Determine whether the operation results in an overflow. All of the addition/subtraction operations in 2"s complement arithmetic, regardless of whether the operands are positive or negative, can be expressed as an addition: The first step is to represent the positive numbers using the 2"s complement representation with 8 bits.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers

Related Documents