CS2630: Computer Organization Homework 1 Bits, bytes, and memory organization Due January 25, 2017, 11:59pm

Similar documents
CS & IT Conversions. Magnitude 10,000 1,

CSCI 2212: Intermediate Programming / C Chapter 15

Where are we? Compiler. translating source code (C or Java) Programs to assembly language And linking your code to Library code

4/8/17. Admin. Assignment 5 BINARY. David Kauchak CS 52 Spring 2017

Bits, Words, and Integers

UNIT 7A Data Representation: Numbers and Text. Digital Data

Under the Hood: Data Representation. Computer Science 104 Lecture 2

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

Where we are going (today)

N.B. These pastpapers may rely on the knowledge gained from the previous chapters.

CS 253. January 14, 2017

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

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

Data III & Integers I

Hexadecimal Numbers. Journal: If you were to extend our numbering system to more digits, what digits would you use? Why those?

ECE 250 / CS 250 Computer Architecture. C to Binary: Memory & Data Representations. Benjamin Lee

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).

Arithmetic and Bitwise Operations on Binary Data

BITS, BYTES, AND INTEGERS

CS 261 Fall Binary Information (convert to hex) Mike Lam, Professor

15110 PRINCIPLES OF COMPUTING SAMPLE EXAM 2

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

COMP2611: Computer Organization. Data Representation

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

Appendix 2 Number Representations

Bitwise Instructions

LAB A Translating Data to Binary

Topic Notes: Bits and Bytes and Numbers

Arithmetic and Bitwise Operations on Binary Data

Birkbeck (University of London) Department of Computer Science and Information Systems. Introduction to Computer Systems (BUCI008H4)

Birkbeck (University of London) Department of Computer Science and Information Systems. Introduction to Computer Systems (BUCI008H4)

Chapter 2: Universal Building Blocks. CS105: Great Insights in Computer Science

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators

Binary Representations and Arithmetic

Binary. Hexadecimal BINARY CODED DECIMAL

COMP 122/L Lecture 2. Kyle Dewey

Data Representation 1

Representation of Information

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

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

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

CS 33. Data Representation, Part 1. CS33 Intro to Computer Systems VII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

Integers. N = sum (b i * 2 i ) where b i = 0 or 1. This is called unsigned binary representation. i = 31. i = 0

CS 241 Data Organization Binary

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

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2

Module 1: Information Representation I -- Number Systems

CS 64 Week 1 Lecture 1. Kyle Dewey

2.1. Unit 2. Integer Operations (Arithmetic, Overflow, Bitwise Logic, Shifting)

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

Data III & Integers I

Memory Addressing, Binary, and Hexadecimal Review

Inf2C - Computer Systems Lecture 2 Data Representation

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

Data III & Integers I

Fundamentals of Programming Session 2

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

EE 109L Final Review

Survey. Motivation 29.5 / 40 class is required

cast int( x float( x str( x hex( int string int oct( int string int bin( int string int chr( int int ord( ch

CS367 Test 1 Review Guide

Computer Organization & Systems Exam I Example Questions

Topic Notes: Bits and Bytes and Numbers

Signed Binary Numbers

Getting started with Java

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

More about Binary 9/6/2016

CSCI2467: Systems Programming Concepts

2SKILL. Variables Lesson 6. Remembering numbers (and other stuff)...

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700: Digital Logic Design Winter Notes - Unit 4. hundreds.

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall Notes - Unit 4. hundreds.

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

Programming Studio #1 ECE 190

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Fall 2018

CS107, Lecture 3 Bits and Bytes; Bitwise Operators

Goals for this Week. CSC 2400: Computer Systems. Bits, Bytes and Data Types. Binary number system. Finite representations of binary integers

MACHINE LEVEL REPRESENTATION OF DATA

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

The Design of C: A Rational Reconstruction"

Octal and Hexadecimal Integers

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

E40M. Binary Numbers, Codes. M. Horowitz, J. Plummer, R. Howe 1

COMP2121: Microprocessors and Interfacing. Number Systems

LING 388: Computers and Language. Lecture 5

CS 31: Introduction to Computer Systems. 03: Binary Arithmetic January 29

EE 109L Review. Name: Solutions

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

data within a computer system are stored in one of 2 physical states (hence the use of binary digits)

UNCA CSCI 255 Exam 1 Spring February, This is a closed book and closed notes exam. It is to be turned in by 1:45 PM.

SECTION II: LANGUAGE BASICS

Question 4: a. We want to store a binary encoding of the 150 original Pokemon. How many bits do we need to use?

Objects and Types. COMS W1007 Introduction to Computer Science. Christopher Conway 29 May 2003

A Java program contains at least one class definition.

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

CS 64 Week 0 Lecture 1. Kyle Dewey

Chapter 3: Operators, Expressions and Type Conversion

Overview. ELEC2041 Microprocessors and Interfacing. Lecture 7: Number Systems - II. March 2006.

15110 Principles of Computing, Carnegie Mellon University - CORTINA. Digital Data

Read this before starting!

Transcription:

CS2630: Computer Organization Homework 1 Bits, bytes, and memory organization Due January 25, 2017, 11:59pm Instructions: Show your work. Correct answers with no work will not receive full credit. Whether you write or type (or both) your answers, save your work as a single PDF file. Upload it on ICON under Assignments > Homework 1. Physical paper copies are not accepted. Goals for this assignment Understand what information can be stored with bits Get comfortable with two s complement Enhance problem solving skills with bit level operations Learn about the organization of memory 1. The internet tells me there are 136 million items in the US Library of Congress. How many bits do you need to name each item uniquely? Assuming we only build an index of the items in US Library of Congress and do not concern ourselves with the real name of the items (which will be quite a pain to remember those words). We need an integer (an unsigned integer would be fine) to index the 136 million items. We need a space of this binary expression, which is a maximum amount of number this binary index can express. The space(possibilities) of N digit binary number is 2 N So 2 N > 136000000 then log 2 136000000 = 27.019031, then N >=28. You can also try calculating 2 28 to verify your result. 2. Using signed integers with two s complement encoding, what is the range of numbers (be precise about the endpoints) that can be represented using the given amount of bits. a. 5 bits b. three bytes (assume 8 bits per bite)

The range should be the most negative and the most positive number one can represent using certain bits. Note that one byte is 8 bits, 3 byte is 24 bits, and signed integer reserved the top bit for the sign. Then the available bit in each option would be 23 for three bytes and 4 for 5 bits. N Thus, for positive end, we have 0 followed by all 1 s, which is 2-1 ( to see this fact write the number 2 N in binary and subtract 1 from it) but for the negative end, we actually can have minus 2 N with 100000 0 (to check, subtract 1 more from 1000 0 and see that you get a positive number) So the range would be [- 2 N N, 2-1] Result: a. [-16, 15] b. [-8388608, 8388607] or in the original notation if you want 3. Convert the following numbers to binary using two s complement encoding. Use at least enough bits to store the entire number. a. -73 10 b. 1013 10 Using the flipping trick or other methods are all approved, as long as they are presented clearly. a. -73 10 = 10110111 (more leading 1 s optional) e.g., 73 / 64 = 1R9, 9/8 = 1R1, so we need one s in exactly the 64 s, 8 s and 1 s places for positive 73 01001001 (shown with leading zero to indicate positive) now invert and add 1 to get -73 01001001 10110110 + 1 10110111 b. 1013 10 = 0110101 1013/512 = 1R501, 501/256 = 1R245, 245/128 = 1R117, 117/64 = 1R53, 53/32 = 1R21, 21/16 = 1R5, 5/4 = 1R1 so we need one s in exactly the 512 s, 256 s, 128 s, 64 s, 32 s, 16 s, 4 s and 1 s places 011 0101(leading zero for positive)

4. Convert the following signed integers (they are shown in binary, two s complement) to decimal. a. 11001010 b. 10101001 Again, lots of ways to do this problem. We show one method. -1*128 + 1*64 + 0*32 + 0*16 + 1*8 + 0*4 + 1*2 + 0*1 = -54 a. 11001010 = -54 10-1*128 + 0*64 + 1*32 + 0*16 + 1*8 + 0*4 + 0*2 + 1*1 = -87 b. 10101001 = -87 10 5. Suppose we create a computer screen out of black/white pixels. Each row of the screen is controlled by a 4-bit number. For example, here we display a letter 0110 à a) Give the hexadecimal digits to display the letter S. (Since you choose the font, show your work!) b) What letter is displayed by entering F9F88 (leftmost digit is top row)? a) You choose the font, so anything looks like a S will do, and it should match the hex digits you wrote. One example is * * 1000 0001

0xF8F1F b) It looks most like a P 6. I hand you a 93 jelly beans and seven jars. You must find a way to distribute the beans into the jars, such that no matter what amount of jelly beans I ask you for (1-93), you can just hand me a combination of the jars (without opening them!) to give me the exact number. This is an interesting one. How do one manage to express any amount with a fixed set of number? Actually this is a mathematical question. And Mathematical question is hard! I for one, do not want to dive into that, so let s go with the safest solution that I can think of. Let s go with binary. Smaller problem first: for any number < 8, we can use some combination of 4,2,1 to express them. Now in this case, we have 93, but only 7 jars, so we can first have 1, 2, 4, 8, 16, 32, and that should give us any number < 64. That s for sure. Now we can express anything (<= 63) and we still have 93 63 = 30 remaining. But for those 30 numbers greater than 63, we can first place 30 beans in last jar. And then the range turn from [64, 93] to [34, 63]. Then we can assemble the leftover with what remains, and we can since the leftover is smaller than 64. Result: 1 2 4 8 16 32 30 7. Suppose I the cable company represents the channels your TV has access to with a 64- bit integer. Each channel from 0 to 63 is represented by one bit, where 1 means the channel is enabled and 0 means channel is disabled. Assume channel 0 is the least significant bit. When you get your cable box, the technician sets the 64-bit code. long A = enabledchannels(); Write code (pseudocode or Java is fine) for the following tasks. You may not call any magic library functions, rather you should just use basic operations like if, for, while, the bitwise operations (~, &, <<, >>,, ^) and integer operations, like ==, <, and >. a. A function that returns whether a particular channel (integer 0-63) is enabled. boolean isenabled(long A, int channel) { } b. A function that returns a new integer, with the given channel enabled. Long enablechannel(long A, int channel) { }

a) boolean isenabled(long A, int channel){ // id start from 0 so no need to minus one down there in the IF If ((A >> channel) && 1) == 1) return TRUE // all those 63 0s in the binary for 1 is to make sure no one else is in my consideration else return FALSE } END b) Long enablechannel (long A, int channel) { long B = 1 B<<channel // shifts 1 to the position of channel return (A B) // enables the channel as we are using OR operation } As long as the program executed by my logical mind give the right answer, you are good. 8. Suppose I have an architecture where the pointers hold 24-bit addresses. The architecture is byte-addressed (i.e., every byte has a unique address). a. How much memory can the computer have (assuming we must name every byte)? Name the amount using the right prefix (i.e., Kibi, Mebi, ). b. Suppose I have an array of 3 pointers. The first byte of the array is at address 0xF00004. What is the address of the last byte in the array? (draw a diagram if it helps) a. 2 24 bytes is 16 MebiByte. Why? Every byte needs a unique name because the machine is byte-addressed and we have 24 bits for addresses. b. 24 bits is 3 bytes, and every pointer is that long. 3 pointers give us 9 bytes and every byte needs an address, so we will give them one. So adding 9 to the starting address. 04 + 9-1 = 12 which is C in hex. The answer would be 0xF0000C. 04+9 gets us to the first byte after the array, subtracting 1 gets us to the very last byte in the array.