Overflow in an 8-bit register

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Overflow in an 8-bit register

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. An 8-bit register adds 11111111 + 00000001. What happens?
A The answer 256 fits in 8 bits
B Overflow: the answer needs a 9th bit
2. Which addition causes overflow in an 8-bit register?
A 100 + 100
B 200 + 100
3. Where does the overflow bit come from?
A A carry out of the leftmost column
B A carry out of the rightmost column
4. What is the result stored in the register when overflow happens?
A Wrong, because the 9th bit is lost
B Correct, because the computer adds an extra bit
5. What is the largest denary result an 8-bit register can store without overflow?
A 255
B 256

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
111111111 + 00000001 = 1 00000000 AA carry out of the leftmost column, so overflow has happened
211001000 + 01100100 = 1 00101100 BIF sum > 255 THEN overflow
3The 8-bit register keeps only 8 bits, so the carried 9th bit is lost and the stored result is wrong CThe answer 0 looks fine, but 255 + 1 = 256 needs 9 bits. The carry out of the leftmost column is lost, so this is an overflow error.
4Overflow happens when the sum of two 8-bit numbers is greater than 255 Dstored result = 00101100 (should be 300)
511111111 + 00000001 = 00000000, no overflow EAn 8-bit register can only hold values up to 255, so 300 cannot be stored and an overflow occurs.
6An 8-bit register can store 100 + 200 = 300 FThe true answer needs 9 bits, because 255 + 1 = 256 is too big for 8 bits

Definitions

overflow

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
11111111 + 00000001 = _________
2.
255 + 1 = 256, which needs _ bits
3.
Result over 255 in 8 bits: ________ error
4.
Overflow: carry out of the ________ column
5.
11111111 + 00000010 = 100000001 Stored in 8 bits: ________

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A max8 <- 256
B total <- 200 + 100
C IF total > max8 THEN
D OUTPUT "Overflow"
E ENDIF
Question 2
A a <- 255
B b <- 1
C bitsNeeded <- 8
D OUTPUT "Overflow"
Question 3
A 11111111 (255)
B + 00000001 (1)
C ----------
D 1 00000000 (255)
Question 4
A total <- 250 + 10
B IF total < 255 THEN
C OUTPUT "Overflow"
D ELSE
E OUTPUT total
F ENDIF
Question 5
A a <- 200
B b <- 100
C total <- a - b
D carry <- total DIV 256
E OUTPUT carry

Answer Key

Overflow in an 8-bit register
Section A: Quick Questions
Q1
B — Overflow: the answer needs a 9th bit
Q2
B — 200 + 100
Q3
A — A carry out of the leftmost column
Q4
A — Wrong, because the 9th bit is lost
Q5
A — 255
Section B: Match the Pairs
Q1
11111111 + 00000001 = 1 00000000 → The true answer needs 9 bits, because 255 + 1 = 256 is too big for 8 bits
Q2
11001000 + 01100100 = 1 00101100 → A carry out of the leftmost column, so overflow has happened
Q3
The 8-bit register keeps only 8 bits, so the carried 9th bit is lost and the stored result is wrong → stored result = 00101100 (should be 300)
Q4
Overflow happens when the sum of two 8-bit numbers is greater than 255 → IF sum > 255 THEN overflow
Q5
11111111 + 00000001 = 00000000, no overflow → The answer 0 looks fine, but 255 + 1 = 256 needs 9 bits. The carry out of the leftmost column is lost, so this is an overflow error.
Q6
An 8-bit register can store 100 + 200 = 300 → An 8-bit register can only hold values up to 255, so 300 cannot be stored and an overflow occurs.
Section C: Definitions
Q1
overflow — An error when an 8-bit addition gives a result over 255. It needs a 9th bit, so the carry out of the leftmost column is lost and the stored result is wrong.
Section D: Fill in the Blanks
Q1
11111111 + 00000001 = 100000000
Q2
255 + 1 = 256, which needs 9 bits
Q3
Result over 255 in 8 bits: overflow error
Q4
Overflow: carry out of the leftmost column
Q5
11111111 + 00000010 = 100000001 Stored in 8 bits: 00000001
Section E: Spot the Error
Q1
A — The largest value an 8-bit register can hold is 255, not 256. 256 needs a 9th bit. It should be max8 <- 255.
Q2
C — 255 + 1 = 256, which is 100000000 in binary and needs 9 bits. An 8-bit register cannot hold it. It should be bitsNeeded <- 9.
Q3
D — The 9-bit answer 100000000 is 256 in denary, not 255. It should be 1 00000000 (256).
Q4
B — Overflow happens when the result is over 255, so the test must use >. It should be IF total > 255 THEN.
Q5
C — Overflow comes from an addition whose result is over 255. Subtracting does not produce it. It should be total <- a + b.