Question: /** Class: ense352 Description: Test code for as1 q1.cpp */ #include #include #include #include q1.h // students must write this file //////////////////////////////////////////////////////////////// // test code

/** Class: ense352 Description: Test code for as1 q1.cpp */

#include #include #include

#include "q1.h" // students must write this file

//////////////////////////////////////////////////////////////// // test code

// FIXME: should rewrite so the type of x can be changed throughout to // short int or simply int. Perhaps a template class

void test_0x89abcdef_0x76543210() { int res = shuffle_words(0x89abcdef, 0x76543210); assert(res == 0x895432ef); } void test_0x00000000_0xfefefefe() { int res = shuffle_words(0x00000000, 0xfefefefe); // the cast to signed is necessary to avoid a compiler warning about // comparison between signed and unsigned integers. assert(res == (signed)0x00fefe00); }

int main() { std::cout

/** Class: ense352 Description: Test code for as1 q1.cpp */ #include #include

1. (5 marks) Implement a C function with the following prototype * Given words x and y, assumed to be at least 32-bits in size, return * a word composed of bytes 0 and 3 of x, and the remaining bytes taken * from y. * For operands \texttt{x = Ox89ABCDEF} and \texttt{y = 0x76543210, this would give \texttt10x895432EF int shufflel_words(int x, int y)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!