Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Comp 211 Midterm 2, Spring 2025, Exams of Computer Science

Comp 211 Midterm 2, Spring 2025

Typology: Exams

2024/2025

Uploaded on 05/04/2025

logan-64
logan-64 🇺🇸

3 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Midterm 2 - A
COMP 211: Systems Fundamentals
Spring 2025
March 21, 2025
Name:
9-digit PID:
Do not begin until given permission.
Honor Code: I have neither given nor received any unauthorized aid on this assessment.
Signed:
pf3
pf4
pf5
pf8

Partial preview of the text

Download Comp 211 Midterm 2, Spring 2025 and more Exams Computer Science in PDF only on Docsity!

Midterm 2 - A

COMP 211: Systems Fundamentals

Spring 2025

March 21, 2025

Name:

9-digit PID:

Do not begin until given permission.

Honor Code: I have neither given nor received any unauthorized aid on this assessment.

Signed:

Question 1: Number Representation and Binary Arithmetic.

1.1. How many bits are in a byte?

1.2. How many bits are in a nibble?

1.3. Circle the most significant byte of the fol- lowing number:

0b1101 0110 1111 0000 1010 1101

1.4. Circle the least significant byte of the fol- lowing number:

0x

1.5. What is the decimal equivalent of the fol- lowing binary value when interpreted as an unsigned integer? A signed two’s comple- ment integer?

0b 10 1001

Unsigned:

Signed:

1.6. How many unique values can be repre- sented with 7 bits?

1.7. What is the range of values that can be represented using 7-bit 2’s complement notation?

1.8. What is the range of values that can be represented using 7-bit unsigned notation?

1.9. Represent -4 as a 4-bit 2’s com- plement value in hexadecimal.

1.10. I want to add together the following two values:

0b 0b

a) If this were an addition between two unsigned numbers, what would be the 4- bit result? Would overflow occur?

Result (decimal):

Overflow (yes/no):

b) If this were an addition between two signed 2’s complement numbers, what would be the 4-bit result? You must pro- vide your answer in decimal to receive credit. Would overflow occur?

Result (decimal):

Overflow (yes/no):

1.11. Which of the following statements are true regarding overflow in binary addition? (Se- lect all that apply.) ⃝ Overflow occurs when the result exceeds the range that can be represented with the given num- ber of bits. ⃝ Overflow occurs in signed and unsigned binary addition when there is a carry out of the last column. ⃝ Overflow always occurs in signed binary addition when adding two numbers of the same sign results in a sum that has a dif- ferent sign. ⃝ If an operation overflowed, the result is incorrect.

Question 3: Memory.

3.1. There is a 15-element int16_t array whose base address is 0xAAAA000010F0.

a) What is the byte address of element 2?

b) What is the byte address of element 7?

c) List all byte addresses that element 3 occupies.

3.2. Answer the following questions based on the memory contents below

Address Data 0xFFFF00004000 0xE842613D 0xFFFF00004004 0xFDA55F 0xFFFF00004008 0x5A408FD 0xFFFF0000400C 0xB08F560E 0xFFFF00004010 0x6BA3D91D 0xFFFF00004014 0xA066EC 0xFFFF00004018 0xF88E911B 0xFFFF0000401C 0x8032E

a) What is the hex value of the 32-bit word stored at 0xFFFF00004010?

b) What is the hex value of the byte stored at 0xFFFF00004012?

c) What is the hex value of the byte stored at 0xFFFF0000401B?

Question 4: Bitwise Operators In digital images, colors are represented using RGB color channels. Each channel controls the intensity of a specific color, and the combination of these three values de- termines the final color. In hexadecimal notation, colors are represented as RRGGBB, where:

  1. RR represents the red component (0x00 to 0xFF in hexadecimal)
  2. GG represents the green component (0x00 to 0xFF in hexadecimal)
  3. BB represents the blue component (0x00 to 0xFF in hexadecimal)

For example, the color 0x4CAF50 consists of: Red: 0x4C, Green: 0xAF Blue: 0x50.

Write a function that takes a hex color code, hex_color, and an integer, increase_amount. The function should increase the intensity of the red channel by increase_amount. If adding increase_amount would make the red channel greater than 255 (0xFF), set the red channel to 255 (0xFF). The function should return the new hex color code after modification.

Example 1 Example 2 hex_color 0x123456 0xF increase_amount 0x40 0x Expected Output 0x523456 0xFF

uint32_t i n c r e a s e _ r e d ( uint32_t hex_color , uint32_t increase_amount ) {

// Step 1 : E x t r a c t the red b i t s

// Step 2 : Increment the r ed c o l o r

// Step 3 : Return the c o l o r with the red m o d i f i c a t i o n

Stack

This page intentionally left blank.