Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I can only use integers constants 0 through 255 (0xFF), inclusive. You are not allowed to use big constants such as 0xffffffff, no global variables,unary

I can only use integers constants 0 through 255 (0xFF), inclusive. You are not allowed to use big constants such as 0xffffffff, no global variables,unary integer operations ! ~, binary integer operations & ^ | + << >>. I can not use any control constructs such as if, do, while, for, switch, etc. Or define or use any macros or define any additional functions in the file or call any functions or use any other operations, such as &&, ||, -, or ?. Nor any form of casting or any data type other than int. This implies that you cannot use arrays, structs, or unions. The machine uses 2s complement, 32-bit representations of integers, performs right shifts arithmetically, and has unpredictable behavior when shifting if the shift amount is less than 0 or greater than 31. Floating point coding rules: You are allowed to use looping and conditional control and both ints and unsigneds. As well as arbitrary integer and unsigned constants. You can use any arithmetic logical, or comparison operations on int or unsigned data. You are forbidden to define or use any macros, define additional functions in the file, call any functions, use any form of casting, use any data type other than int or unsigned. This means that you cannot use arrays, structs, or unions. Or use any floating point data types, operations, or constants. Example of acceptable coding style: /* * pow2plus1 - returns 2^x + 1, where 0 <= x <= 31 */ int pow2plus1(int x){ .* exploit ability of shifts to compute powers of 2 */ return ( 1 << x) +1; } The question from my assignment is "Extract byte n from word x, Bytes numbers from 0 (LSB) to 3 (MSB). Example: function_name(0x12345678, 1) = 0x56. The operations I can use are: & << >> and I can only a maximum of 3 operations. function outline: int function_name(int x, int n) { return ; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions