Introduction to Computer Science. Homework 1

Similar documents
The CPU and Memory. How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram:

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

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

Chapter 4. Operations on Data

1. Which of the following Boolean operations produces the output 1 for the fewest number of input patterns?

Computer Organization and Levels of Abstraction

COS 140: Foundations of Computer Science

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

Chapter 2 Data Manipulation

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

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

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

The von Neumann Architecture. IT 3123 Hardware and Software Concepts. The Instruction Cycle. Registers. LMC Executes a Store.

Binary Adders: Half Adders and Full Adders

CS101 Lecture 04: Binary Arithmetic

Computer Organization and Levels of Abstraction

Introduction to Computer Science Lecture 2: Data Manipulation

Dec Hex Bin ORG ; ZERO. Introduction To Computing

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

Digital Systems. John SUM Institute of Technology Management National Chung Hsing University Taichung, ROC. December 6, 2012

Chapter 2: Data Manipulation

Chapter 2: Data Manipulation

Register Transfer and Micro-operations

CS 261 Fall Mike Lam, Professor Integer Encodings

More Programming Constructs -- Introduction

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,...

Introduction to Computers & Programming

SISTEMI EMBEDDED. Basic Concepts about Computers. Federico Baronti Last version:

Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates. Invitation to Computer Science, C++ Version, Third Edition

Chapter 3: part 3 Binary Subtraction

ASSEMBLY LANGUAGE MACHINE ORGANIZATION

Chapter 5 12/2/2013. Objectives. Computer Systems Organization. Objectives. Objectives (continued) Introduction. INVITATION TO Computer Science 1

Software and Hardware

CS101 Lecture 25: The Machinery of Computation: Computer Architecture. John Magee 29 July 2013 Some material copyright Jones and Bartlett

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

1. Draw general diagram of computer showing different logical components (3)

Experimental Methods I

Diskrečioji matematika

COMP2611: Computer Organization. Data Representation

Chapter 4. Combinational Logic

Von Neumann Architecture

Arab Open University. Computer Organization and Architecture - T103

Basic Processing Unit: Some Fundamental Concepts, Execution of a. Complete Instruction, Multiple Bus Organization, Hard-wired Control,

CS 24: INTRODUCTION TO. Spring 2015 Lecture 2 COMPUTING SYSTEMS

Wednesday, February 4, Chapter 4

Data Manipulation. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan

Computer Architecture and Data Manipulation. Von Neumann Architecture

CMPUT 101 with Solutions Quiz 2 (50 minutes) November 16, 2000

Number System. Introduction. Decimal Numbers

2.2 THE MARIE Instruction Set Architecture

11/22/1999 7pm - 9pm. Name: Login Name: Preceptor Name: Precept Number:

COMPUTER ARCHITECTURE AND ORGANIZATION Register Transfer and Micro-operations 1. Introduction A digital system is an interconnection of digital

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

ECE 341 Midterm Exam

Introduction to Computers and Programming. Numeric Values

that system. weighted value associated with it. numbers. a number. the absence of a signal. MECH 1500 Quiz 2 Review Name: Class: Date:

ECE/Comp Sci 352 Digital Systems Fundamentals. Charles R. Kime Section 2 Fall Logic and Computer Design Fundamentals

Chapter 2: Data Manipulation. Copyright 2015 Pearson Education, Inc.

Introduction to Computer Science-103. Midterm

Register Transfer Language and Microoperations (Part 2)

DC57 COMPUTER ORGANIZATION JUNE 2013

2c. Content of Computer systems (Component 01)

Chapter 1. Digital Systems and Binary Numbers

Chapter 5. Algorithms. Introduction. Chapter 5 Algorithms. Search algorithms. Linear search. Worked example

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

Programming Using C Homework 5

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

Chapter 4. The Processor. Instruction count Determined by ISA and compiler. We will examine two MIPS implementations

CDA 3103 Computer Organization Exam 1 (Sep. 22th, 2014)

EE292: Fundamentals of ECE

World Inside a Computer is Binary

Chapter 10 - Computer Arithmetic

Parallel logic circuits

Fundamentals of Programming Session 1

ALU Design. 1-bit Full Adder 4-bit Arithmetic circuits. Arithmetic and Logic Unit Flags. Add/Subtract/Increament/Decrement Circuit

Chapter 4. The Processor

Floating Point. The World is Not Just Integers. Programming languages support numbers with fraction

Little Man Computer (LMC)

Computer Architecture and Organization: L04: Micro-operations

Midterm Exam Review. CS 2420 :: Fall 2016 Molly O'Neil

Full file at

UNIT-II. Part-2: CENTRAL PROCESSING UNIT

Computer Organization II CMSC 3833 Lecture 33

Introduction to MiniSim A Simple von Neumann Machine

THE LOGIC OF COMPOUND STATEMENTS

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

OCR H446 A-Level Computer Science

CC411: Introduction To Microprocessors

The LC3's micro-coded controller ("useq") is nothing more than a finite-state machine (FSM). It has these inputs:

Number Systems (2.1.1)

4. Write a sum-of-products representation of the following circuit. Y = (A + B + C) (A + B + C)

Chapter 5: Computer Systems Organization. Invitation to Computer Science, C++ Version, Third Edition

Chapter 5: Computer Systems Organization

Representation of Information

Learning objectives. Computer principles The characteristics of contemporary processors, input, output and storage devices

PART A (22 Marks) 2. a) Briefly write about r's complement and (r-1)'s complement. [8] b) Explain any two ways of adding decimal numbers.

Computer Organisation CS303

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

CS/EE1012 INTRODUCTION TO COMPUTER ENGINEERING SPRING 2013 HOMEWORK I. Solve all homework and exam problems as shown in class and sample solutions

Number Systems and Computer Arithmetic

Transcription:

Introduction to Computer Science Homework. In each circuit below, the rectangles represent the same type of gate. Based on the input and output information given, identify whether the gate involved is an AND, OR, or XOR. (8 points) a. AND 0 0 b. OR 0 c. XOR 0 2. If the input and output bit patterns in the circuit below are interpreted as binary representations of numeric values, what operation does the circuit perform (8 points) (You would get only part of grade if your answer is not complete.) ANS: The circuit subtracts one (except for the case of the input being 000).

3. Solve each of the following problems by translating the values into two s complement notationn (using patterns of five bits), converting any subtraction problem to an equivalent addition problem, and performing that addition. (8 points) Example: a. - b. c. d. e. 4. Which of the following values cannot be represented accurately in the floating-point format introduced in the bel2w figure. (8 points) (If your answer only contains b or d, you would get half of grade) a. 6 2 b. 9 c. 3 6 d. 7 32

ANS: b would require too large of an exponent. d would require too many significant digits. 5. If a term paper consisted 42 pages, each containing 40 lines of 00 symbols each (counting each space as a symbol), was to be encoded using Unicode, how many bytes of storage space would be required (5 points) ANS: 336,000 bytes (68,000 symbols times 2 bytes per symbol) 6. Explain why adding only a few characters to a text file may increase the file s size by several hundred bytes and at other times may not increase the file s size at all. (5 points) ANS: File space is allocated in terms of physical records, each of which is several hundred bytes in size. Thus, the size of a file grows by physical record units rather than by byte size units. 7. In which of the following situations does an overflow never occur Justify an answer. (2 points) (8 points from the answer B, D. 4 points from the explanation of your answer) (a) Adding two positive integers (b) Adding one positive integer to a negative integer (c) Subtracting one positive integer from a negative integer. (d) Subtracting two negative integers. ANS: (a) Overflow can occur because the magnitude of the result is greater than the magnitude of each number and could fall out of the presentable range. (b) Overflow does not occur because the magnitude of the result is smaller than one of the numbers; the result is in the presentable range. (c) When we subtract a positive integer from a negative integer, the magnitudes of the numbers are added. This is the negative version of case a. Overflow can occur. (d) When we subtract two negative numbers, the magnitudes are subtracted from each other. This is the negative version of case b. Overflow does not occur. overflow does not occur in (b) and (d). 8. Multiple Choice Questions ( 單選題 ) (0 points) i. Which of the following is not contained in a CPU ANS: D

A. Instruction register B. Program counter C. General-purpose register D. Memory cell ii. In which of the following locations is information most readily available for manipulation by the CPU ANS: A A. General-purpose registers B. Main memory C. Mass storage iii. The bus in a computer is an example of which form of communication ANS: B A. Serial B. Parallel C. Neither A nor B iv. Which of the following instructions does not fall in the category of arithmetic/logic instructions ANS: D A. ROTATE B. ADD C. OR D. JUMP v. Which of the following is not an activity performed entirely within a CPU ANS: A A. Fetch instructions B. Perform Boolean operations C. Perform arithmetic operations D. Move data between registers 9. Describe the machine cycle. (9 points) ANS: Fetch an instruction and increment the program counter, decode the instruction, and execute the instruction. 0. Suppose three values x, y, and z are stored in a machine s memory. Describe the sequence of events (such as, loading registers from memory, saving values in memory, and so on) that leads to the computation (9 points) a. x + y + z b. (2x) + y ANS: To compute x + y - z, each of the values must be retrieved from memory and placed in a register, the sum of x and y must be computed and saved in another register, z must be subtracted from that sum, and the final answer must be stored in memory. A similar process is required to compute (2x) + y. The point of this example is that the multiplication by 2 is accomplished by adding x to x.. Suppose the memory cells at addressed 00 through 05 in the machine described in Appendix C of the textbook contain the following bit patterns:

(9 points) Address Content 00 2 0 04 02 3 03 00 04 C0 05 00 Assuming the program counter initially contained 00, record (a) the contents of the program counter, (b) instruction register, and (c) memory cell at address 00 at the end of each fetch phase of the machine cycle until the machine halts. ANS: 2. Suppose the memory cells at addressed 00 through 0D in the machine described in Appendix C of the textbook contain the following bit patterns: (9 points) Address Contents 00 20 0 03 02 2 03 0 04 40 05 2 06 5 07 2 08 B 09 0C 0A B0 0B 06 0C C0 0D 00 Assume that the machine starts with its program counter containing 00. (a) What bit pattern will be in register when the machine halts (b) What bit pattern will be in register 0 when the machine halts

(c) What bit pattern is in the program counter when the machine halts ANS: a. 03 b. 03 c. 0E