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 "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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started