Birla Institute of Technology
Birla Institute of Technology
Nature of Exam : Closed Book Weightage : 40% Duration : 2 Hours Date of Exam : 20/09/2003 (AN) Note : Attempt all the questions. Start each answer from a fresh page. Q. 1. Perform the following operations using 8-bit 2s complement representation and show the individual steps. If the operation results in an error or exception mention the same and explain why. [2 + 2 = 4] a) 125 15 b) 128 53 Q. 2. Explain how you can implement the following operations using only 2-input NOR gates: [1+2+2+1=6] a) NOT b) AND c) XOR d) EQUALS (Note: EQUALS operation is defined as follows: A EQUALS B is 1 if A=B=0 or if A=B=1 and 0 otherwise. End of Note.) Q.3. (a) What is the role of the Program Counter in the Von-Neumann model of a computer? (b) Identify the following components as part of Control Unit, Processing Unit, Memory Unit or Input/Output Unit of a computer based on the von-Neumann model: i) Keyboard ii) Instruction Register iii) Temporary register iv) Memory Address Register [2 + 4 x 0.5 = 4]
Q. 4. Explain the different addressing modes available in LC-2 Instruction Set using STORE instruction (or its variations). [6] Q. 5. Consider the following LC-2 assembly program fragment: .ORIG x3000 AND R2, R2, #0 ADD R2, R2, #4 LOOP BRz DONE ADD R2, R2, #-1 ADD R3, R3, R3 BRnzp LOOP DONE HALT .END [3+2+1=6]
a) The program is intended for shifting R3 to the left by 4 bits, but has an error in it. Identify the error and explain how to fix it.
b) Show the symbol table corresponding to this program after it has gone through the first phase of the assembler. c) Explain the role of .ORIG pseudo-op in the above program. Q.6. (a) (b) Differentiate between an interpreter and a compiler. Give 1 argument each in favor of and against the following statement: It is better to program in a high-level programming language than in an assembly programming language. [2+2=4] Q. 7. Give a flow-chart for checking whether a given character occurs in a sequence of characters. Assume that your target machine is LC-2, the input character is stored in register R1, the starting address of the input sequence is stored in R2 and you need to store the result (0 or 1) in R3. [6] Q. 8. Which of the following are valid declarations of variables in C? If a declaration is valid, what is the range of values that can be assigned to the variable? If it is not valid, mention a reason. Assume a 32-bit machine. (i) (ii) (iii) (iv) unsigned int x; int y; char int z; typedef char;
[4]
_________