


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A programming assignment for csc 2400 students in the fall 2008 semester. The assignment focuses on bit-level representations and manipulations, with the goal of gaining a deeper understanding of how operations are performed and data is handled in the system. Students are required to complete a series of programming puzzles using only straightline code and a limited number of c arithmetic and logical operators. Instructions on how to set up the project, compile it, and submit the solution electronically.
Typology: Assignments
1 / 4
This page cannot be seen from the preview
Don't miss anything!
The purpose of this assignment is to become more familiar with bit-level representations and manipulations, and ultimately gain a deeper understanding of how operations are performed and data is handled in the system. You’ll do this by solving a series of programming “puzzles.” Many of these puzzles are quite artificial, but you’ll find yourself thinking much more about bits in working your way through them.
You may work in a group of up to two people in solving the problems for this assignment. The only “hand- in” will be electronic. Any clarifications and revisions to the assignment will be posted on the course Web page.
Step 1. Make a directory called datalab in your home directory (mkdir datalab).
Step 2. Copy Makefile, btest.c, bits.c and countops.pl from /mnt/a/tway/datalab to your own datalab directory using the cp command. The only file you will modify is bits.c.
Note: make sure that you login to a machine other than csgate to perform your work (i.e., degas, cezanne, tanner, picasso, rodin, cassatt, gauguin, or matisse).
Step 3. Use the command make to compile the project, then type btest to run it. Repeat this step each time you make a modification to your bits.c file and want to test it.
Step 4. In bits.c, edit the team members character string variable to include the name, or names, of your programming team members.
The bits.c file also contains a skeleton for each of the 16 programming puzzles. Your assignment is to complete each function skeleton using only straightline code (i.e., no loops or conditionals) and a limited number of C arithmetic and logical operators. Specifically, you are only allowed to use the following eight operators:
Name Description Rating Max Ops bitNor(x,y) ˜(x|y) using only & and ˜ 1 8 bitXor(x,y) ˆ using only & and ˜ 2 14 isNotEqual(x,y) x != y? 2 6 getByte(x,n) Extract byte n from x 2 6 copyLSB(x) Set all bits to LSB of x 2 5 logicalShift(x,n) Logical right shift x by n 3 16 bitCount(x) Count number of 1’s in x 4 40 bang(x) Compute !x without using! operator 4 12 leastBitPos(x) Mark least significant 1 bit 4 30
Table 1: Bit-Level Manipulation Functions.
A few of the functions further restrict this list. Also, you are not allowed to use any constants longer than 8 bits. See the comments in bits.c for detailed rules and a discussion of the desired coding style.
Evaluation
Your code will be compiled with GCC and run and tested on one of the class machines. Your score will be computed out of a maximum of 80 points based on the following distribution:
42 Correctness of code running on one of the class machines.
32 Performance of code, based on number of operators used in each function.
6 Style points, based on your instructor’s subjective evaluation of the quality of your solutions and your comments.
The 16 puzzles you must solve have been given a difficulty rating between 1 and 4, such that their weighted sum totals to 42. We will evaluate your functions using the test arguments in btest.c. You will get full credit for a puzzle if it passes all of the tests performed by btest.c, half credit if it fails one test, and no credit otherwise.
Regarding performance, our main concern at this point in the course is that you can get the right answer. However, we want to instill in you a sense of keeping things as short and simple as you can. Furthermore, some of the puzzles can be solved by brute force, but we want you to be more clever. Thus, for each function we’ve established a maximum number of operators that you are allowed to use for each function. This limit is very generous and is designed only to catch egregiously inefficient solutions. You will receive two points for each function that satisfies the operator limit.
Finally, we’ve reserved 6 points for a subjective evaluation of the style of your solutions and your com- menting. Your solutions should be as clean and straightforward as possible. Your comments should be informative, but they need not be extensive.
Advice
You are welcome to do your code development using any system or compiler you choose. Just make sure that the version you turn in compiles and runs correctly on our class machines. If it doesn’t compile, we can’t grade it.
The countops.pl program is very basic perl program that counts the ops used in your file, and also looks for the use of any illegal operators or constants that are too large. Run it from the command line by typing tt countops.pl bits.c.
Hand In Instructions
Note: This lab is based heavily on a similar lab prepared by the authors of our textbook.