CS1011 & CS1041 - August/September 1998 - Pete Jinks Students taking CS1011 answer Question 1 and one other question from Section A. Students taking CS1041 answer Question 4 from Section B. Answer each section in a separate answer book. Section A: Answer this section in a separate answer book. 1. Fill in the blanks in the following sentences. Indicate your answers by writing down the part letters (a) to (t) and (A) to (T) in order and for each, a suitable missing word, number or phrase. Each part is worth half a mark. [20 marks This is only the first half of question 1. Peter Capon writes the second half. MU0 is a simple computer, consisting of two main components, the (a)_____ and memory. MU0 instructions can be classified into those that mainly use the (b)_____ register, such as (c)_____, and those that mainly use the (d)_____ register, such as (e)_____. In operating systems, such as UNIX, (f)_____ are used to store information, and are collected together in directories. Because (g)_____, the filestore is referred to as being tree-structured. In the (h)_____ century, Babbage reinvented the concept of the Difference Engine, used to (i)_____, and invented the concept of the (j)_____. The programming languages (k)_____, (l)_____ and (m)_____ are examples of the imperative, functional and logic paradigms respectively. Of these three paradigms, (n)_____ is/are also described as procedural, and (o)_____ is/are also described as declarative. Programs written in a high level language are translated to (p)_____ by a compiler. This usually contains three analysis phases: lexical, where (q)_____, syntactic, where (r)_____, and semantic, where (s)_____. These three phases are then usually followed by the (t)_____ phase. 2. Answer THREE of the following parts in as much detail as you can in the time available. Each part is worth the same amount. [20 marks a. Detail the steps required to locate, access, decode and execute a ADD instruction in the MU0 computer. How would the steps required differ for a JMP instruction? State clearly the movement of information between the components of the MU0 computer at each step. Why are most such movements of information routed via the ALU, instead of using separate special-purpose routes? b. Write a sequence of MU0 assembly language instructions that will divide one positive integer (x) by another (y) to give an approximate result. Base your answer on the following algorithm: /* divide x by y to give result */ result= 0 if (y==0) stop repeat x= x-y if (x<0) stop result= result+1 Remember to declare any variables that you use (including x and y). Ignore any problems that might arise from values being too big to fit in a word. Assume that your program will be modified by the user to put specific values into the variables x and y. Marks are awarded for the correctness of your MU0 instructions, not their efficiency. c. Programmers using imperative languages have to write programs in a different way from programmers using functional languages, even though the languages share some features. Describe some of the features that most imperative languages and functional languages share. Describe some of the differences between programs written in an imperative language and in a functional language. d. Explain how a product-number is encoded as an EAN bar-code, and how the bar-code is decoded. Describe how the information obtained is processed in a typical EPOS system in a shop. Question 3 is written by Peter Capon. Section B: Answer this section in a separate answer book. Question 4, for CS1041, is written by John Latham.