ENCE 3241 Data Lab. 60 points Due February 19, 2010, by 11:59 PM

Similar documents
CS 105 Lab 1: Manipulating Bits

CMSC 311 Spring 2010 Lab 1: Bit Slinging

CS 2505 Fall 2013 Data Lab: Manipulating Bits Assigned: November 20 Due: Friday December 13, 11:59PM Ends: Friday December 13, 11:59PM

Data Lab: Manipulating Bits

MCS-284, Fall 2015 Data Lab: Manipulating Bits Assigned: Sept. 22, Due: Tues., Sept. 29, 11:59PM

CS 2505 Fall 2018 Data Lab: Data and Bitwise Operations Assigned: November 1 Due: Friday November 30, 23:59 Ends: Friday November 30, 23:59

CMSC 201, Fall 2014 Data Lab: Manipulating Bits Assigned: Sept. 03, Due: Wed., Sept. 17, 11:59PM

CS 356, Fall 2018 Data Lab (Part 1): Manipulating Bits Due: Wednesday, Sep. 5, 11:59PM

BIL220, Spring 2012 Data Lab: Manipulating Bits Assigned: Feb. 23, Due: Wed., Mar. 8, 23:59PM

CS-281, Spring 2011 Data Lab: Manipulating Bits Assigned: Jan. 17, Due: Mon., Jan. 31, 11:59PM

EECS 213, Spring 2013 Data Lab: Manipulating Bits

Data Lab: Manipulating Bits

ECEn 424 Data Lab: Manipulating Bits

CS 356, Fall 2018 Data Lab (Part 2): Manipulating Bits Due: Mon, Sep. 17, 11:59PM

15-213, Spring 2008 Lab Assignment L1: Manipulating Bits Assigned: Jan. 15, Due: Wed., Jan. 30, 11:59PM

FALL 2017 CSCI 304 LAB2 (Due on October-10, 11:59:59pm)

Project Data: Manipulating Bits

CS 241 Data Organization using C

Project 4: Implementing Malloc Introduction & Problem statement

CS33 Project Gear Up. Data

CSC 2400: Bit Manipulation Assignment

It is academic misconduct to share your work with others in any form including posting it on publicly accessible web sites, such as GitHub.

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

Digital Design and Computer Architecture Harris and Harris, J. Spjut Elsevier, 2007

15-110: Principles of Computing, Spring 2018

CS 241 Data Organization. August 21, 2018

Arithmetic and Bitwise Operations on Binary Data

COMP 3500 Introduction to Operating Systems Project 5 Virtual Memory Manager

Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time)

Programming Tips for CS758/858

15213 Recitation Section C

Integers II. CSE 351 Autumn Instructor: Justin Hsia

CS 113: Introduction to

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes

Problem Set 6 Audio Programming Out of 40 points. All parts due at 8pm on Thursday, November 29, 2012

CS 61C: Great Ideas in Computer Architecture Lecture 2: Introduction to C, Part I

ANITA S SUPER AWESOME RECITATION SLIDES. 15/18-213: Introduction to Computer Systems Bit Logic and Floating Point, 27 January 2014 Anita Zhang

3. When you process a largest recent earthquake query, you should print out:

FALL 2017 CSCI 304 LAB1 (Due on Sep-19, 11:59:59pm)

CMPSCI 187 / Spring 2015 Hanoi

CS3114 (Fall 2013) PROGRAMMING ASSIGNMENT #2 Due Tuesday, October 11:00 PM for 100 points Due Monday, October 11:00 PM for 10 point bonus

Final Programming Project

Introduction to Computer Systems

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

Integers II. CSE 351 Autumn 2018

Question Points Score Total: 100

CSE 351: The Hardware/Software Interface. Section 2 Integer representations, two s complement, and bitwise operators

Lab 1: Dynamic Memory: Heap Manager

PCS1-Ch-3B-Basic-Loops-HW CSCI 1320 Initials P a g e 1

ENCM 369 Winter 2019 Lab 6 for the Week of February 25

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

Programming Assignment #4 Arrays and Pointers

OOP-15-AVL Final Project-1-HW Individual Assignment 70 Points

15-213/18-213/15-513, Spring 2018 C Programming Lab: Assessing Your C Programming Skills

Arithmetic-logic units

Spring 2016, Malloc Lab: Writing Dynamic Memory Allocator

Tips from the experts: How to waste a lot of time on this assignment

EECE.2160: ECE Application Programming

Project #1: Tracing, System Calls, and Processes

Exercise Session 2 Systems Programming and Computer Architecture

Project 3: RPN Calculator

Tips from the experts: How to waste a lot of time on this assignment

Problem Set 1 Due: 11:59pm Wednesday, February 7

CMPSCI 187 / Spring 2015 Implementing Sets Using Linked Lists

gcc o driver std=c99 -Wall driver.c bigmesa.c

Lab 1: Silver Dollar Game 1 CSCI 2101B Fall 2018

Introduction to Computer Engineering (E114)

BITWISE OPERATORS. There are a number of ways to manipulate binary values. Just as you can with

MCS-284, Fall 2018 Cache Lab: Understanding Cache Memories Assigned: Friday, 11/30 Due: Friday, 12/14, by midnight (via Moodle)

CS 110 Computer Architecture. Lecture 2: Introduction to C, Part I. Instructor: Sören Schwertfeger.

Read this before starting!

CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point?

CS 110 Computer Architecture. Lecture 2: Introduction to C, Part I. Instructor: Sören Schwertfeger.

CS131 Compilers: Programming Assignment 2 Due Tuesday, April 4, 2017 at 11:59pm

CMPSC 111 Introduction to Computer Science I Fall 2016 Lab 2 Assigned: September 7, 2016 Due: Wednesday, September 14, 2016 by 2:30 pm

CSC201, SECTION 002, Fall 2000: Homework Assignment #2

Foundations of Computer Systems

Programming Studio #1 ECE 190

Assignment 1. CSI Programming Practice, Fall 2011

CS 211 Programming I for Engineers

CS 211 Programming Practicum Fall 2018

In case you didn t get it (or you were too lazy to check)

CpSc 1111 Lab 9 2-D Arrays

SPRING 2017 CSCI 304 LAB1 (Due on Feb-14, 11:59:59pm)

Systems Programming and Computer Architecture ( ) Exercise Session 01 Data Lab

CMPSC 111 Introduction to Computer Science I Fall 2016 Lab 8 Assigned: October 26, 2016 Due: November 2, 2016 by 2:30pm

Unate Recursive Complement Algorithm

CS 3114 Data Structures and Algorithms DRAFT Project 2: BST Generic

The print queue was too long. The print queue is always too long shortly before assignments are due. Print your documentation

Project 1 Balanced binary

CS261: HOMEWORK 2 Due 04/13/2012, at 2pm

Distributed: Monday, Nov. 30, Due: Monday, Dec. 7 at midnight

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

15-110: Principles of Computing, Spring 2018

15-213/18-213/15-513, Fall 2017 C Programming Lab: Assessing Your C Programming Skills

Read this before starting!

Programming Assignment 3

Introduction to Computer Systems

CAD4 The ALU Fall 2009 Assignment. Description

Transcription:

0 Introduction ENCE 3241 Data Lab 60 points Due February 19, 2010, by 11:59 PM The purpose of this assignment is for you to become more familiar with bit-level representations and manipulations. 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 pairs for this assignment, if you wish. No groups of more than two people are permitted. You do not have to work with the same person you worked with on other labs. I highly recommend you work in pairs. Compiler: We will grade using, and your programs must compile and run under CygWin on, GCC version 3.4.4 under Linux kernel version 2.6. If you do not use this environment for development of your solutions, we strongly recommend that you test them under it. Source: This lab was derived, through varying paths and amounts of change, from the Data Lab provided in the instructor s package that goes along with Bryant and O Hallaron. 1 Getting started We provide you with a zip file datalab.zip. Download this file to your computer, and unpack it as usual or with the following command: % tar xf datalab.tar (Ooops! Ignore this) This will create a directory datalab containing many files. The only file you may modify is bits.c. Your assignment is to complete each function skeleton using only straighline code, i.e. no loops or conditionals, and a limited number of arithmetic and logical operators. Specifically, you are allowed to use the following eight operators:! ~ & ^ + >> <<

A few of the functions further restrict this list. See the comments in bits.c for detailed rules and a discussion of the desired coding style. 2 Instructions Your goal is to modify your copy of bits.c so that it passes all the tests without violating any of the coding guidelines. 2.1 Modifying bits.c and checking it with dlc Carefully read the instructions in bits.c before you start. These give the coding rules you are required to follow. I have not provided the dlc progrm to check your code for compliance with the rules; to verify the compliance of your modifications to bits.c, you have to follow the rules. 2.2 Testing for correctness with btest If your modifications to bits.c meet the coding rules, it is then time to check whether the functions work correctly. We have provided a makefile and some additional C code to combine with your code, creating a test harness; this program will be called btest. Build it with the following command: % make btest Then, test your code with: %./btest -e3 tee btest.output btest can give voluminous output; the above will save it into a file called btest.output, in addition to displaying it on the screen. Also, the above command limits the number of errors reported per puzzle to three if you wish, you can vary the number after -e to change the limit, or omit the flag for no limit. Please note: you must rebuild the test harness each time you modify bits.c.

2.3 Puzzles The following are the bit-manipulation functions which you must implement. Each puzzle has a difficulty rating from one to four. Additionally, each puzzle has a target number of operations to earn full credit, your solution cannot exceed this. 1. bitand(x, y): Calculate the bitwise and of x and y, i.e. (x&y), using only ~ and. Difficulty rating: 1; maximum operation count: 8. 2. tmin(): Return the minimum two s complement integer (Note the restriction on constants). Difficulty rating: 1; maximum operation count: 4. 3. isnotequal(x, y): Return 0 if x == y, and 1 otherwise. Difficulty rating: 2; maximum operation count: 6. 4. negate(x): Return x. Difficulty rating: 2; maximum operation count: 5. 5. logicalshift(x, n): Shift x to the right by n, using a logical shift. Difficulty rating: 3; maximum operation count: 16. 6. isgreater(x, y): Return 1 if x > y, else return 0. Difficulty rating: 3; maximum operation count: 24. 7. tc2sm(x): Convert from two s complement to sign-magnitude where the MSB is the sign bit. Difficulty rating: 4; maximum operation count: 15. 8. bitcount(x): Returns the number of 1 s in the binary representation of x. Difficulty rating: 4; maximum operation count: 40. 2.4 Grading The score given by btest is the rating score for your work. To compute your grade, we will use the following table. Each difficulty level has two puzzles.

Rating Points per puzzle Total points 1 3 6 2 6 12 3 9 18 4 12 24 Example: btest reports 3.20/4.00 for bitparity(), which is a rating-4 puzzle. This converts to a grade of 9.6/12 on that puzzle. 1 Additionally, we will deduct up to 20% per-puzzle if your operation count exceeds the limit. If the number of operations used is equal to or less than the limit, there is no deduction; if the number of operations is twice the limit or more, we will deduct 20%. Between these, we will linearly scale the deduction based on your operation count. Example, continued: The limit for bitparity() is 20 operations. The 9.6-point solution uses 30 operations. This is halfway between the limit (20) and twice the limit (40), so the deduction is half of 20%, or 10%; the 9.6-point score on that puzzle is reduced by 10% to 8.64/12. 3 Suggestions In solving these puzzles, you may wish to consult the following sources: Also: The textbook, 2.1.8-2.1.10, including the practice problems whose solutions are in the back of the chapter. Also, see 2.3.6 and 2.3.7. C by Dissection, the first part of Chapter 3 on logical operators, and Appendix C on bitwise operators. K&R 2 2.9. Use the right computer. Use the right compiler. 1 You may notice that the above is simply multiplying the btest score by 3. This is correct, though the following paragraph complicates things. 2 The C Programming Language by Kernighan and Ritchie

Ensure both dlc and btest are happy with your work. Change only files you re supposed to. Follow submission instructions. Keep backup copies. Use the identities of Boolean algebra or truth tables to show some logical equivalence of Boolean functions. 4 Submission instructions 4.1 Readme file Please submit only the files listed in this section using the Digital Drop Box. Submit: 1. bits.c 2. README The readme file contains meta-information about you and your work, and should contain the following sections. This file must be well-organized and clear, and please name it README exactly. 3 Team. Names, student ID numbers, section numbers, and email addresses of all team members. GCC version. Include the first line of output from gcc --version. (This double-checks that you are using the tools we require for this assignment.) Miscellaneous info. Any other information you want to tell us about your programs. (This section is optional.) 3 Please don t name it readme, Readme, README.TXT, or anything other than README.