Programming Studio #1 ECE 190

Similar documents
Programming Studio #1 ECE 190

COMP Overview of Tutorial #2

MACHINE LEVEL REPRESENTATION OF DATA

CSCE 212H, Spring 2008, Matthews Lab Assignment 1: Representation of Integers Assigned: January 17 Due: January 22

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

World Inside a Computer is Binary

Inf2C - Computer Systems Lecture 2 Data Representation

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Introduction to Computers and Programming. Numeric Values

CHW 261: Logic Design

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example

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

Number Systems. Both numbers are positive

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

COMP2611: Computer Organization. Data Representation

CS 101: Computer Programming and Utilization

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Number representations

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

Number Systems CHAPTER Positional Number Systems

Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers

Part 2,Number Systems Questions

Recitation #1 Boot Camp. August 30th, 2016

Lab 1 Introduction to UNIX and C

Unit 10. Linux Operating System

CMSC 201 Spring 2017 Lab 01 Hello World

Recitation #1 Unix Boot Camp. August 29th, 2017

CMSC 201 Spring 2018 Lab 01 Hello World

CS & IT Conversions. Magnitude 10,000 1,

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

Digital Fundamentals

ECOM 2325 Computer Organization and Assembly Language. Instructor: Ruba A.Salamah INTRODUCTION

unused unused unused unused unused unused

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

User Guide Version 2.0

BINARY SYSTEM. Binary system is used in digital systems because it is:

Signed Binary Numbers

CMPSCI 145 MIDTERM #1 Solution Key. SPRING 2017 March 3, 2017 Professor William T. Verts


Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as:

Operations On Data CHAPTER 4. (Solutions to Odd-Numbered Problems) Review Questions

DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location What to bring:

Python for Astronomers. Week 1- Basic Python

The ALU consists of combinational logic. Processes all data in the CPU. ALL von Neuman machines have an ALU loop.

Final Labs and Tutors

Octal & Hexadecimal Number Systems. Digital Electronics

Unit 13. Linux Operating System Debugging Programs

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

8/30/2016. In Binary, We Have A Binary Point. ECE 120: Introduction to Computing. Fixed-Point Representations Support Fractions

Signed umbers. Sign/Magnitude otation

The type of all data used in a C++ program must be specified

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

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

Introduction to Algorithms and Programming I Lab. Exercises #1 Solution

Lecture 01 - Working with Linux Servers and Git

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

History. Terminology. Opening a Terminal. Introduction to the Unix command line GNOME

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

CSE115 Lab exercises for week 1 of recitations Spring 2011

FLOATING POINT NUMBERS

Binary Representations and Arithmetic

Chapter 2: Number Systems

Data Representation. DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

Numbering systems. Dr Abu Arqoub

EE292: Fundamentals of ECE

CENG 334 Computer Networks. Laboratory I Linux Tutorial

CHAPTER 1 Numerical Representation

CMPE223/CMSE222 Digital Logic Design. Positional representation

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude

Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit

Tutorial 1: Unix Basics

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras

A Level Computing. Contents. For the Exam:

Number System. Introduction. Decimal Numbers

Working with Basic Linux. Daniel Balagué

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

COMP2121: Microprocessors and Interfacing. Number Systems

Carnegie Mellon. Linux Boot Camp. Jack, Matthew, Nishad, Stanley 6 Sep 2016

Introduction to Linux. Fundamentals of Computer Science

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

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

Lab Working with Linux Command Line

15213 Recitation 2: Floating Point

Chapter 4. Operations on Data

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

LAB WORK NO. 2 THE INTERNAL DATA REPRESENTATION

Objectives. Connecting with Computer Science 2

TOPIC: NUMBER SYSTEMS

C NUMERIC FORMATS. Overview. IEEE Single-Precision Floating-point Data Format. Figure C-0. Table C-0. Listing C-0.

Chapter 3: Number Systems and Codes. Textbook: Petruzella, Frank D., Programmable Logic Controllers. McGraw Hill Companies Inc.

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

Lecture 2: Number Systems

Course Syllabus [1/2]

Transcription:

Programming Studio #1 ECE 190

Programming Studio #1 Announcements Recitation Binary representation, hexadecimal notation floating point representation, 2 s complement In Studio Assignment Introduction to Linux Command-Line Operations

Announcements Homework 1 Is available on the website. Drop off in basement of Everitt Lab in the ECE 190 Drop Box No late homework accepted. If it s not in the drop box by 5pm on due date, it receives a zero, no excuses. Programming Studio Attendance Policy If you score below average on any exam you must go to all but one studio before the next exam. If you fail to meet this requirement you will not be allowed to take the next exam. In order to receive credit for attending a programming studio, you must completely finish lab assignments given during the studio time slot or put in a reasonable effort into solving said problem Cheating Policy We actively scan for cheating cases on exams, homeworks, and Machine Problems There is a difference between working to find a solution together and sharing code/answers (the latter is NOT allowed). Course information View the syllabus on the website for deadlines, rules, etc. Check website frequently for announcements Use the web board through my.ece to ask questions

Binary Representation 1 and 0 are the only digits. This is a base 2 counting system Left hand bit is the MSB (Most Significant Digit), right hand bit is the LSB (Least Significant Digit) Binary -> decimal conversion: Multiply each digit by 2 n where n is the number of places away from the right-most bit Sum all the products together Ex: 1110 2 = 1*2 3 + 1*2 2 + 1*2 1 + 0*2 0 = 14 10 Decimal -> binary conversion Divide the number by two, if the remainder is 0, the bit is 0, otherwise it is 1 Subtract the remainder from the decimal value Repeat the above two steps until the decimal value is 0 Ex: 6 10 => 6/2 = 3.0 => bit: 0 3/2 = 1.5 => bit: 1 => 110 2 1/2 = 0.5 => bit: 1

Hexadecimal Representation Concept is the same as binary, except its base 16 instead of 2 Digits range from 0 to F To indicate the number is a hexadecimal place an x in front Hexadecimal -> Decimal Conversion Exactly as in binary, but multiply each digit by 16 n Ex: x1f = 1*16 1 + F * 16 0 = 16 + 15 = 31 10 Decimal -> Hexadecimal The same as in binary, but divide by 16, remainder values 10 to 15 are represented by letters A to F Ex: 27 10 => 27/16 = 1 r 11 => xb 1/16 = 0 r 1 => x1 => x1b Decimal -> Binary (Shortcut) First convert the decimal to hexadecimal, then convert each hex digit to a 4-bit binary

2 s Complement A way to represent negative numbers in binary If the MSB is 1 the bit pattern represents a negative number. But you can t just multiply each bit by a power of 2 to find its value To find its magnitude: perform 1 s complement (change all the 1 s to 0 s and vice versa) Add 1 Use the standard binary->decimal method to obtain the magnitude Ex: 1011 => 0100 => 0100 + 1 => 0101 => 5 10. So 1011 2 is -5 10 What about 100 2? To convert from decimal to 2 s complement convert the absolute value of the decimal number to binary as before. If the original decimal value is negative, perform 1 s complement on that binary representation and add 1 to it What is the decimal range of an n-bit 2 s complement representation?

Floating Point Need a way to represent non integers in binary The common representation follows a standard set by IEEE (IEEE-754) 32 bits needed for single precision, 64 bits for double Sign bit: 1 if number is negative, 0 if it is positive Mantissa: normalized so that it always contains an implied 1 in front of the most significant bit Exponent: 127 + n, where n is the number of places the decimal point was shifted to the left in order to normalize the mantissa (n can be a negative number if we shifted the decimal point to the right)

Representation If you see a binary number 1011, what is its value? It s just a bit pattern, the person reading it adds meaning to it If we treat it as an unsigned notation the decimal value is 11 If we treat it as a signed 2 s complement notation the decimal value is -5 Or we could interpret it as a different encoding, like floating point

Programming Studio Assignment: Introduction to Linux

Log into your machine Logging In Use your netid and AD password If you cannot log in because you are not an engineering student ask your TA to create an account for you If you are using a Windows workstation you must connect to an EWS Linux machine using SSH Open PuTTY In the Host Name box type remlnx Make sure the Port is set to 22 Click Open When prompted to log in, use your netid and AD password It is possible to connect to an EWS workstation from home. Look on the EWS website for instructions

Working in Command Line Instead of pointing and clicking we tell the computer what to do by typing a command Most of the ECE tools are only command line based In Linux, open the Terminal application to enter command line mode To see which directory you are in type pwd Initially you should be in /home/engr/your_net_id To see the contents of the current directory type ls To see more details about the contents type ls l To obtain help for most Linux commands/programs type man <command_name> Let s see the help information for the ls command Type: man ls

Creating/changing directories We use the mkdir dir_name command to create a directory called dir_name Create a directory called mydir Type mkdir mydir Confirm that a directory was created by typing ls and seeing that the mydir directory shows up in the list To enter into a directory we use the cd command Type cd mydir to enter the mydir directory To exit to the parent directory of mydir type cd../

Moving Files/Directories Make sure you are out of the mydir directory Type pwd to confirm you are in your home directory Create a directory called dir2 Type mkdir dir2 To move dir2 using the mv source dest command Type mv dir2 mydir Make sure you moved it to mydir Type ls mydir to see the contents inside mydir Many times you will want to make backup copies of files/directories by using the cp command Make a backup copy of mydir and call it mydir_backup by executing: cp r mydir mydir_backup The -r tells the copy command to also make a copy of all the contents inside mydir. If you are copying files you don t need it Type ls to confirm that you made a backup copy

Deleting Files/Folders We use the rm command to delete things WARNING! This is an irreversible operation. There is no way to undo it. Make sure you use this command with caution and double check before your press ENTER. If you accidentally delete a project file it will be lost for ever. To delete a file called filename type rm filename Try to delete mydir by typing rm mydir To delete a directory you must add a -r after rm: rm r mydir You will be prompted to confirm that you want to delete it as well as the contents inside of it To delete it without having to confirm type rm rf mydir

Practice Practice creating directories, renaming them using the mv command, deleting them, changing in and out of directories, printing their contents When you are done type exit to close the terminal and/or close the SSH connection. Make sure to log out of your machine