Question: 2. [20] Suppose we number the bytes in a 32-bit word from 0 (least significant) to 3 (most significant) and that the word consists of
![2. [20] Suppose we number the bytes in a 32-bit word](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f158cc75c0c_93966f158cbdea0d.jpg)
2. [20] Suppose we number the bytes in a 32-bit word from 0 (least significant) to 3 (most significant) and that the word consists of 4 individual signed bytes. Write code for the following C function that will return byte i of x sign extended to 32 bits: unsigned int extract (unsigned int x, int i); Here are some test runs: extract (0x12345678, 0) 0x00000078 extract (0xABCDEF00, 2) 0xFFFFFFCD Use only bitwise operators and subtraction; no if statements, loops, or other arithmetic operators (+, *, /, %). Also write a main() function to test your function. Hint: arithmetic shift is your friend with regard to sign extension. Name your source file 2-2.c
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
