Data Lab: Manipulating Bits

Slides:



Advertisements
Similar presentations
Microcomputer Systems 1
Advertisements

1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 2: Data types and addressing modes dr.ir. A.C. Verschueren.
CSE 351 Midterm Review. Your midterm is next Wednesday Study past midterms (link on the website) Point of emphasis: Registers are not memory Registers.
Fixed Point Numbers The binary integer arithmetic you are used to is known by the more general term of Fixed Point arithmetic. Fixed Point means that we.
10/9: Lecture Topics Starting a Program Exercise 3.2 from H+P Review of Assembly Language RISC vs. CISC.
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
2.3) Example of program execution 1. instruction  B25 8 Op-code B means to change the value of the program counter if the contents of the indicated register.
Socratic Method, Understanding Floats. Float Cheat Sheet ExponentSignificandValue 000 0nonzeroDenorm 1~ 2 E - 2Anything+/- fl. Pt # 2 E - 1 (all 1s)0+/-
Lecture 16: Computer Arithmetic Today’s topic –Floating point numbers –IEEE 754 representations –FP arithmetic Reminder –HW 4 due Monday 1.
When NOT to use Unsigned? Don’t Use Just Because Number Nonzero – C compilers on some machines generate less efficient code unsigned i; for (i = 1; i
Fabián E. Bustamante, Spring 2007 Integers Today Numeric Encodings Programming Implications Basic operations Programming Implications Next time Floats.
Chapter 2 Representing and Manipulating Information Prof. Qi Tian CS 3843 Fall
Number Systems Standard positional representation of numbers:
CS213 Integers Apr 3, 2006 Topics Numeric Encodings
1 Lecture 3 Bit Operations Floating Point – 32 bits or 64 bits 1.
Recitation # Section F Spring 2006 Jernej Barbic.
Major Numeric Data Types Unsigned Integers Signed Integers Alphanumeric Data – ASCII & UNICODE Floating Point Numbers.
ICS 2005 Instructor: Peter A. Dinda TA: Bin Lin Recitation 1.
Introduction Computer program: an ordered sequence of instructions whose objective is to accomplish a task. Programming: process of planning and creating.
Floating Point Numbers
Operations on data CHAPTER 4.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Integer Data representation Addition and Multiplication.
Simple Data Type Representation and conversion of numbers
Carnegie Mellon 1 This Week: Integers Integers  Representation: unsigned and signed  Conversion, casting  Expanding, truncating  Addition, negation,
Chapter 1 Data Storage(3) Yonsei University 1 st Semester, 2015 Sanghyun Park.
Number Systems So far we have studied the following integer number systems in computer Unsigned numbers Sign/magnitude numbers Two’s complement numbers.
Computer Architecture
1 Bit Operator. Advanced Compiler Laboratory2 Bit operators ! : invert logical value if value is 0 change to 1, otherwise set to 0 ~ : invert all bits.
C Tokens Identifiers Keywords Constants Operators Special symbols.
Data Representation in Computer Systems
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
9.4 FLOATING-POINT REPRESENTATION
Engineering Computing I Chapter 1 – Part A A Tutorial Introduction.
8-1 Embedded Systems Fixed-Point Math and Other Optimizations.
ECE-1021 Course Review. Engineering Problem Solving ä Define the problem clearly ä Work hand examples ä Develop the Algorithm ä Implement the Algorithm.
CISC105 – General Computer Science Class 9 – 07/03/2006.
CSC 4250 Computer Architectures September 5, 2006 Appendix H. Computer Arithmetic.
15213 Recitation Section C Introduction Unix and C Playing with Bits Practice Problems Shimin Chen Sept. 9, 2002 Outline.
CS 105 “Tour of the Black Holes of Computing” Topics Numeric Encodings Unsigned & Two’s complement Programming Implications C promotion rules Basic operations.
Data Representation : Introduction to Computer Systems Recitation 2: Monday, Jan. 29th, 2015 Dhruven Shah.
CSI 3125, Preliminaries, page 1 Data Type, Variables.
CS 105 “Tour of the Black Holes of Computing” Topics Numeric Encodings Unsigned & Two’s complement Programming Implications C promotion rules Basic operations.
Carnegie Mellon 1 Midterm Review : Introduction to Computer Systems Recitation 8: Monday, Oct. 14, 2013 Marjorie Carlson Section A.
Structures and Union. Review bitwise operations –you need them for performance in terms of space and time –shifts are equivalent to arithmetics enumeration.
Numbers in Computers.
Computer Architecture Lecture 11 Arithmetic Ralph Grishman Oct NYU.
Integers Topics Representations of Integers Basic properties and operations Implications for C.
10/7/2004Comp 120 Fall October 7 Read 5.1 through 5.3 Register! Questions? Chapter 4 – Floating Point.
King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department.
1 Manipulating Information (1). 2 Outline Bit-level operations Suggested reading –2.1.7~
1 Binghamton University Exam 1 Review CS Binghamton University Birds eye view -- Topics Information Representation Bit-level manipulations Integer.
Floating Point Arithmetic – Part I
Lecture 6. Fixed and Floating Point Numbers
2.0 FUNDAMENTALS OF JAVA PROGRAMMING LANGUAGE
PRESENTED BY J.SARAVANAN. Introduction: Objective: To provide hardware support for floating point arithmetic. To understand how to represent floating.
S09 Recitation #1 Jernej Barbic (S06) Revised: Alex Gartrell (S09)
Floating Point Math, Fixed-Point Math and Other Optimizations
Recitation: Data Lab The TAs Sep 11, 2017.
Number Representations
Comp Integers Spring 2015 Topics Numeric Encodings
FIGURE 9-1 Graph for Example of Conversion from Infix to RPN
Chapter 2 Representing and Manipulating Information
Lab Project #1: Datalab Assigned March 12, 2012; due March 22, 11:59 PM Professor Hugh C. Lauer CS-2011, Machine Organization and Assembly Language.
Operations and Arithmetic
Review In last lecture, done with unsigned and signed number representation. Introduced how to represent real numbers in float format.
CS 286 Computer Architecture & Organization
Chapter 2 Representing and Manipulating Information
Number Representations
Computer Architecture and System Programming Laboratory
Chapter 1 Introduction.
Presentation transcript:

Data Lab: Manipulating Bits

Introduction Purpose: To be more familiar with bit-level representations of integers and floating point numbers. Individual project Programming environment Linux server: 117.16.244.185 Telnet & login with your ID & password

Handout instructions Start by copying datalab-handout.tar to a directory using the command cp /var/share/datalab-handout.tar . tar xvf datalab-handout.tar This will cause a number of files to be unpacked in the directory. The only file you need to modify is bits.c. bits.c Contains a skeleton for 15 programming puzzles. You must complete each function skeleton using only straight-line code for integer puzzles (no loops or conditionals). Only allowed 8 operators: ! ~ & ^ | + << >> You are not allowed to use any constants longer than 8 bits.

Puzzles Bit manipulations Rating: difficulty (also the number of points) Max ops: the maximum number of operators allowed to use to implement each function

Puzzles Two’s complement arithmetic

Puzzles Floating-point operations You can used standard control structures (loops, conditionals). You may use both int and unsigned data types, including arbitrary integer and unsigned constants. You may not use union, struct, or array. Any floating point operand will be passed to the function as having type unsigned, and any returned floating point value will be of type unsigned. float_neg & float_twice must handle the full range of possible argument values including NaN and infinity.

Helper programs fshow ishow Helps you understand the structure of floating point numbers. You can use fshow to see that an arbitrary pattern represents as a floating point number Example # ./fshow 2080374784 Floating point value 2.658455992e+36 Bit Representation 0x7c000000, sign = 0, exponent = 0xf8, fraction = 0x000000 Normalized. +1.0000000000 X 2^(121) ishow Helps you understand the structure of integer numbers.

Compile Switch to the handout directory and type make

Evaluation Correctness points: 41 Performance points: 30 By executing btest, points are automatically evaluated. Performance points: 30 2 points for each function satisfying the operator limits. dlc is used to evaluate the number of operators. Bonus points: 6 Student(s) who implement the functions bitCount, ilog2, and float_i2f with the smallest number of operators will be given 2 points. A student may get 6 bonus points at maximum. The number of operators should be smaller than the operator limits. It should be done during the Lab time.