15-213/18-213 Fall 2012 Data Lab: Manipulating Bits Assigned: Thu, Aug 30, Due: Thu, Sep 13, 11:59PM Last Possible Time to Turn in: Sun, Sep 16, 11:59PM
For the fastest response, please contact the staff via the mailing list (email@example.com) for questions about the assignment.
The purpose of this assignment is to become more familiar with bit-level representations of common patterns, integers, and ﬂoating-point numbers. You’ll do this by solving a series of programming “puzzles.” Many of these puzzles are quite artiﬁcial, but you’ll ﬁnd yourself thinking much more about bits in working your way through them.
• This is an individual project. All handins are electronic using the Autolab service. • You should do all of your work in an Andrew directory, using either the shark machines or a Linux Andrew machine.
3 Logging in to Autolab
All 15-213 labs are being offered this term through a Web service developed by CMU students and faculty called Autolab. Before you can download your lab materials, you will need to update your Autolab account. Point your browser at the Autolab front page https://autolab.cs.cmu.edu You will be asked to authenticate via WebISO. After you authenticate this ﬁrst time, Autolab will prompt you to update your account information with a nickname. Your nickname is the external name that identiﬁes 1
you on the public scoreboards that Autolab maintains for each assignment, so pick something interesting! You can change your nickname as often as you like. Once you have updated your account information, click on “Save Changes” button, and then select the “Home” link to proceed to the main Autolab page. If you added the class late, you might not be included in Autolab’s list of valid students. In this case, you won’t see the 15-213/18-213 course listed on your Autolab home page. If this happens, just contact the staff.
4 Handout Instructions
Your lab materials are contained in a Unix tar ﬁle called datalab-handout.tar, which you can download from Autolab. After logging in to Autolab at https://autolab.cs.cmu.edu you can retrieve the datalab-handout.tar ﬁle by selecting “Data Lab − > Download handout”. Start by copying datalab-handout.tar to the Linux Andrew directory in where you plan to do your work. Then give the command linux> tar xvf datalab-handout.tar This will create a directory called datalab-handout that contains a number of ﬁles. The only ﬁle you will be modifying and handing in is bits.c. The bits.c ﬁle contains a skeleton for each of the 13 programming puzzles. Your assignment is to complete each function skeleton following a strict set of coding rules: You may use only straightline code for the integer puzzles (i.e., no loops or conditionals) and a limited number of C arithmetic and logical operators. Speciﬁcally, you are only allowed to use the following eight operators: ! ˜ & ˆ | + > 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 coding rules for each functions. WARNING: Do not let the Windows WinZip program open up your .tar ﬁle (many Web browsers are set to do this automatically). Instead, save the ﬁle to your AFS directory and use the Linux tar program to extract the ﬁles. In general, for this class you should NEVER use any platform other than Linux to modify your ﬁles, doing so can cause loss of data (and important work!).
5 The Puzzles
This section describes the puzzles that you will be solving in bits.c.
5.1 Bit Manipulations
Table 1 describes a set of functions that manipulate and test sets of bits. The “Rating” ﬁeld gives the difﬁculty rating (the number of points) for the puzzle, and the “Max ops” ﬁeld gives the maximum number of operators you are allowed to use to implement each function. See the comments in bits.c for more details on the desired behavior of the functions. You...
Please join StudyMode to read the full document