Birkbeck (University of London) Department of Computer Science and Information Systems Introduction to Computer Systems (BUCI008H4) CREDIT VALUE: none Spring 2017 Mock Examination 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 9 c Birkbeck College 2017
1. Show your working in all parts of this question. (a) Add the binary numbers 10010 and 1011. (b) Subtract the binary number 1011 from the binary number 10011. 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. (d) Convert the binary number 10110 to the corresponding decimal number. (e) Convert the hexadecimal numbers A and B to the corresponding decimal numbers, add the decimal numbers and convert the result to hexadecimal form. BUCI008H4 Page 2 of 9 c Birkbeck College 2017
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. (b) 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. 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 rightmost three bits of the bit string obtained by adding s and t as if they were binary numbers. BUCI008H4 Page 3 of 9 c Birkbeck College 2017
3. (a) State the name of one binary Boolean operation. Explain the meaning of the word binary in this context. (b) 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). Describe one way in which Boolean operations are used in programming languages. 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. Question 4 continued on next page BUCI008H4 Page 4 of 9 c Birkbeck College 2017
(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) (b) 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. BUCI008H4 Page 5 of 9 c Birkbeck College 2017
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. (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). BUCI008H4 Page 6 of 9 c Birkbeck College 2017
(b) 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) BUCI008H4 Page 7 of 9 c Birkbeck College 2017
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. (b) State one advantage in using a high level programming language to implement algorithms. 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. BUCI008H4 Page 8 of 9 c Birkbeck College 2017
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. (b) If the memory cell for the value 1 is x then what is the memory cell for the value 9? 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. BUCI008H4 Page 9 of 9 c Birkbeck College 2017