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

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

Mid-term Examination

Introduction to Computer Science-103. Midterm

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

Chapter 4. Operations on Data

COMP1917 Computing 1 Written Exam Sample Questions

Sample Examination. Family Name:... Other Names:... Signature:... Student Number:...

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

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

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

Introduction to Computers and Programming. Numeric Values

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

COMP Overview of Tutorial #2

FLOATING POINT NUMBERS

Chapter 3: Arithmetic for Computers

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

Number System. Introduction. Decimal Numbers

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

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

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

Bits, Words, and Integers

±M R ±E, S M CHARACTERISTIC MANTISSA 1 k j

18. Machine Language. Computer Systems. COMP1917: Computing 1. Machine Language Programming. History of Computer Technology

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

FLOATING POINT NUMBERS

Name: CMSC 313 Fall 2001 Computer Organization & Assembly Language Programming Exam 1. Question Points I. /34 II. /30 III.

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

Read this before starting!

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)

CS101 Lecture 04: Binary Arithmetic

Experimental Methods I

Read this before starting!

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.

MACHINE LEVEL REPRESENTATION OF DATA

Number Systems CHAPTER Positional Number Systems

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

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM

Birkbeck (University of London) MSc Examination. Department of Computer Science and Information Systems. Fundamentals of Computing (COIY058H7)

Chapter 2 Bits, Data Types, and Operations

Computer Organisation CS303

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

CS & IT Conversions. Magnitude 10,000 1,

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

Binary. Hexadecimal BINARY CODED DECIMAL

Number representations

Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur

Read this before starting!

Chapter 2 Bits, Data Types, and Operations

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

UNIVERSITY OF WISCONSIN MADISON

Chapter 2 Bits, Data Types, and Operations

Set Theory in Computer Science. Binary Numbers. Base 10 Number. What is a Number? = Binary Number Example

Read this before starting!

Declaring Floating Point Data

ECE 30 Introduction to Computer Engineering

Software and Hardware


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

Signed Binary Numbers

Data Representation 1

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

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

Numerical Representations On The Computer: Negative And Rational Numbers

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

IBM 370 Basic Data Types

Numerical Representations On The Computer: Negative And Rational Numbers

Signed umbers. Sign/Magnitude otation

WYSE Academic Challenge 2002 Computer Science Test (Sectional) SOLUTION

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

Reals 1. Floating-point numbers and their properties. Pitfalls of numeric computation. Horner's method. Bisection. Newton's method.

Divide: Paper & Pencil

Exponential Notation

Chapter 2. Data Representation in Computer Systems

Chapter 1. Data Storage Pearson Addison-Wesley. All rights reserved

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers

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

Logic, Words, and Integers

Signed Multiplication Multiply the positives Negate result if signs of operand are different

Objectives. Connecting with Computer Science 2

Chapter 3 Data Representation

Read this before starting!

CONCORDIA UNIVERSITY Department of Computer Science and Software Engineering COMP 228/4 Section PP Midterm Exam

Lecture 2: Number Systems

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

COMPUTER ARCHITECTURE AND ORGANIZATION. Operation Add Magnitudes Subtract Magnitudes (+A) + ( B) + (A B) (B A) + (A B)

THE LOGIC OF COMPOUND STATEMENTS

Binary Addition & Subtraction. Unsigned and Sign & Magnitude numbers

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.

Computer Science 121. Scientific Computing Winter 2016 Chapter 3 Simple Types: Numbers, Text, Booleans

CS2214 COMPUTER ARCHITECTURE & ORGANIZATION SPRING 2014

CHAPTER TWO. Data Representation ( M.MORRIS MANO COMPUTER SYSTEM ARCHITECTURE THIRD EDITION ) IN THIS CHAPTER

Chapter Three. Arithmetic

Chapter 2 Bits, Data Types, and Operations

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

In this lesson, we will use the order of operations to evaluate and simplify expressions that contain numbers and variables.

Moodle WILLINGDON COLLEGE SANGLI. ELECTRONICS (B. Sc.-I) Introduction to Number System

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

Chapter 2 Bits, Data Types, and Operations

Logic and Computer Design Fundamentals. Chapter 1 Digital Computers and Information

Digital Fundamentals

Transcription:

Birkbeck (University of London) Department of Computer Science and Information Systems Introduction to Computer Systems (BUCI008H4) CREDIT VALUE: none Spring 2017 Mock Examination SUMMARY ANSWERS Date: Tuesday 14th March 2017 Duration: 18.00 19.20 NAME: There are seven questions in this paper. Answer all seven questions. Each question carries 10 marks in total. Calculators and other electronic devices are not permitted. The examination is closed book. No supplementary material is provided. This paper is not prior disclosed. BUCI008H4 Page 1 of 6 c Birkbeck College 2016

1. Show your working in all parts of this question. (a) Add the binary numbers 10010 and 1011. Answer: 11101. Two marks. One mark for the correct answer without any working. Subtract the binary number 1011 from the binary number 10011. Answer: 1000. Two marks. One mark for the correct answer without any working. Multiply 2 10, i.e. two to the power ten, and 2 13, i.e. two to the power thirteen. An answer in the form of a power of two is required. Answer: 2 23. Two marks. One mark for the correct answer without any working such as 23 = 10 + 13. (d) Convert the binary number 10110 to the corresponding decimal number. Answer: 22. Two marks. One mark for the correct answer without any working. (e) Convert the hexadecimal numbers A and B to the corresponding decimal numbers, add the decimal numbers and convert the result to hexadecimal form. Answer: A is decimal 10 and B is decimal 11. Add to obtain decimal 21, which is hexadecimal 15. Two marks 2. Show your working in all parts of this question. (a) Write out the table for the three bit excess notation for integers. Show clearly the integers which can be represented using the three bit excess notation. Answer: 4 marks. 1/2 mark for each correct entry in the following table. 3 111 2 110 1 101 0 100-1 011-2 010-3 001-4 000 Obtain the four bit two s complement representations for the integers -1 and 2. Obtain from these two s complement representations the two s complement representation for the integer 1. Note that -1+2 is equal to 1. Answer: 1111 and 0010. On adding these bit strings as if they are binary numbers the bit string 10001 is obtained. The rightmost 4 bits of 10001 are the two s complement representation for 1. 4 marks. One mark for each correct two s complement representation of -1, 2 and 1. One mark for a correct addition. Find two integers m, n with corresponding three bit excess representations s, t, such that i) m + n has a three bit excess representation u; and ii) u is not equal to the BUCI008H4 Page 2 of 6 c Birkbeck College 2016

rightmost three bits of the bit string obtained by adding s and t as if they were binary numbers. Answer: Two marks for any correct answer, e.g. m = 0, n = 1. 3. (a) State the name of one binary Boolean operation. Explain the meaning of the word binary in this context. Answer: Two marks for naming any binary Boolean operation such as AND, OR, Exclusive OR, etc. A truth table is not required. Two marks for stating that the term binary indicates that the Boolean operation acts on pairs of values. Four marks in total. Write out the truth table for the Boolean operation A == B. If A and B have the same value, then A == B is true (1 or T is also accepted), otherwise A == B is false (0 or F is also accepted). Answer: One mark for each correct row, making four marks in total. A B A == B 0 0 1 0 1 0 1 0 0 1 1 1 Describe one way in which Boolean operations are used in programming languages. Answer: Boolean operations are used to make decisions about the flow of control in a program. Two marks. Two marks if the answer consists of a reasonable example. Relational operators such as < are not counted as Boolean operators. 4. The Brookshear floating point representation for a binary fraction x consists of eight bits, labeled s, e 1, e 2, e 3, m 1, m 2, m 3, m 4 from left to right. If x is zero, then all eight bits are zero. If x is strictly negative, then the sign bit s is 1. If x is strictly positive, then the bit s is zero. Next, suppose x is not zero. To obtain the remaining seven bits, x is written in the form ±2 r 0.t where r is an integer and t is a bit string such that the leftmost bit of t is 1. The bits e 1, e 2, e 3 together comprise the three bit excess notation for r and the bits m 1, m 2, m 3, m 4 of the mantissa are the leftmost four bits of t. (a) Obtain the Brookshear floating point representation for the decimal fraction 1/16. In your answer show the value of r and the value of the bit string 0.t. (8 marks) Answer: 00011000 (four marks), r = 3 (two marks) and 0.t = 0.1000 (two marks), making eight marks in total. BUCI008H4 Page 3 of 6 c Birkbeck College 2016

Suppose that the Brookshear floating point representation for a non-zero number x is given. Explain how it is possible to obtain quickly the Brookshear floating point representation for the number 2x, under the assumption that the representation of 2x exists. Answer: Increase the exponent by 1. Two marks. One mark for an example without any statement of the general method. 5. The table included below in this question describes instructions of length 16 bits, made by concatenating an op-code and an operand. The first four bits record the op-code. The remaining 12 bits record the operand. Four bits are required to specify a register R and eight bits are required to specify a memory location XY. Each register holds eight bits and each memory location holds eight bits. Each 16 bit instruction is coded by four hexadecimal digits. For example, the four hexadecimal digits 37A9 specify an instruction with op-code 3, in which the 7 refers to register 7 and A9 refers to the memory cell A9. The registers are numbered in hexadecimal from 0 to F. All memory addresses in this question are given in hexadecimal notation. Op code Operand Description 1 RXY Load register R with the bit pattern in memory cell XY. 2 RXY Load register R with the bit pattern XY. 3 RXY Store the bit pattern in register R at memory cell XY. 4 0RS Move the bit pattern in register R to register S. 5 RST Add (two s complement) the bit patterns in registers R and S. Put the result in register T. 6 RST Add (floating point) the bit patterns in registers R and S. Put the result in register T. 7 RST Or the bit patterns in registers S and T. Put the result in register R. 8 RST And the bit patterns in registers S and T. Put the result in register R. 9 RST Exclusive Or the bit patterns in registers S and T. Put the result in register R. A R0X Rotate the bit pattern in register R one bit to the right X times. B RXY Jump to the instruction in memory cell XY if the bit pattern in register R is equal to the bit pattern in register 0. C 000 Halt. BUCI008H4 Page 4 of 6 c Birkbeck College 2016

(a) Describe the result of the instruction 9312 when register 1 contains A6 (in binary 10100110) and register 2 contains F F (in binary 11111111). Register 3 contains the bit string 01011001. Four marks. Two marks for stating that the result appears in register 3 and two marks for the correct bit string. One mark if it is stated that the bits in register 1 are flipped without any further answer. Write a program in machine code to i) read the contents of the memory cell with the hexadecimal address 91 into register 1; then ii) flip the bits of the bit string in register 1 and put the resulting bit string in register 3; and finally iii) copy the bit string in register 3 to the memory cell with address 91. The bits in a bit string are flipped by converting 0 to 1 and 1 to 0. For example, if the bit string is 00110011, then flipping the bits yields the bit string 11001100. (6 marks) Answer: 1191 22FF 9312 3391 Six marks. Any reasonable answer accepted, including 1191, 9312, 3391 in which it is assumed that register 2 already contains FF. Two marks deducted for each mistake. 6. (a) Give a definition of the term algorithm. Give a definition of the term variable, as this term might be used when describing an algorithm. Answer: An algorithm is an ordered sequence of unambiguous executable steps that defines a terminating process. Two marks. Two marks for any reasonable variation in this wording. For example, an algorithm is a finite sequence of executable instructions. A variable is a named memory location or a variable is a quantity that has a name and a value. Either answer is accepted. Two marks. State one advantage in using a high level programming language to implement algorithms. Answer: An algorithm can be programmed using fewer instructions than would be required in a machine code version of the same algorithm. Two marks. Any reasonable answer accepted. Consider the following statement. To convert degrees centigrade into degrees Fahrenheit, multiply by 9/5 and add 32. This statement is to be the basis for an algorithm. Identify the input and the output of the algorithm. Suggest two variables that might be used in an implementation of this algorithm. Answer: The input is a number of degrees centigrade. The output is the corresponding number of degrees Fahrenheit. The two variables could be the number c of degrees centigrade and the number f of degrees Fahrenheit. Four marks. One mark for each item. BUCI008H4 Page 5 of 6 c Birkbeck College 2016

7. Recall that an array is a block of values of the same type, for example, A = ( 1 2 ) 4 0 9 6 The indexing of the rows and columns of an array starts in each case from 0 and the index for the rows is given first. For example, A[0, 1] has the value 2. (a) Describe one way in which the array A might be stored in a computer memory. Use a diagram to show clearly where the different values in A are placed. You may assume that each entry of A is stored in a single memory cell. Answer: row major order is assumed in this answer but other arrangements, e.g. column major order, are accepted. The rows of A are placed in memory side by side. Four marks. Full marks given for a diagram. 1 2 4 0 9 6 If the memory cell for the value 1 is x then what is the memory cell for the value 9? Answer: x + 4. Two marks Let x be the memory cell in which A[0, 0] is stored. Show how the location of the memory cell holding A[i, j] can be calculated using the values of x, i and j. Answer: x + 3i + j. Four marks. BUCI008H4 Page 6 of 6 c Birkbeck College 2016