Starting from:

$24.99

CS382 Solution

CS 382 Computer Architecture

1 Task: An Array of Nibbles
In this lab, we’re going to create an array of nibbles. Say we have an integer array: int arr[2] = {0xEFF2, 0x9812} we can use bit-wise operations and shifting to create an array like this: unsigned char nibs[16] = {0,0,0,0,0xE,0xF,0xF,0x2,0,0,0,0,0x9,0x8,0x1,0x2} . Note how many 0 are there in nibs : each integer takes four bytes which is eight nibbles, so you need to make sure leading zeros are also considered in the array. Since there’s no data type that contains only four bits, we use unsigned char as a substitute.
The function you are going to implement is declared as follows:

where intarr is the integer array, nint the number of integers in that array, nibarr the array of nibbles that you’re going to fill in, and nnibs the size of that array.
You can assume both nint and nnibs are correct.

1
Requirements
Your code must be able to compile successfully and executed without segmentation fault or any other type
errors;
as comments;
You must not change the function declaration of int_to_nibble() .
2 Grading
The lab will be graded based on a total of 10 points.
the code does not compile, or executes with run-time error;
-5: included other header files, and/or the starter code was changed (except main() );
-5: the result is incorrect;
-3: leading zeros in the integer numbers are not stored as nibbles; -1: no pledge and/or name(s) in C file.

Attendance: check off at the end of the lab to get attendance credit.

2

More products