Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
FCVAC/IAS2123/AUG16 MIDTERM EXAMINATION AUGUST 2016 SEMESTER EXAMINATION ACADEMIC SESSION 2015 SUBJECT SUBJECT CODE DURATION FACULTY : COMPUTER ORGANIZATION COMPUTER ORGANIZATION ARCHITECTURE : IAS2123/IID2163 : 2 HOURS : COMPUTER SCIENCE AND INFORMATION TECHNOLOGY INSTRUCTION TO CANDIDATES Answer all questions. Student Name Matric No Program Total Marks ANSWER SCHEME MID TERM CONFIDENTIAL/1 FCVAC/IAS2123/AUG16 SECTION A (15 MARKS) Answer ALL questions. For each question choose the best answer. 1. Which of the following will be used by a computer to execute all programs written on it? A. Active language B. System language C. Machine language D. Interpreted language 2. Which utility program reads an assembly language source file and produces an object file? A. Linker B. Loader C. Compiler D. Assembler 3. A device driver would ordinarily be written in which language? A. machine language B. assembly language C. an application-oriented language D. a platform-independent language, such as Java 4. Integer range of American Standard Code for Information Interchange codes (ASCII) is _____________. A. -128 to +127 B. 0 to 127 C. 0 to 270 D. 0 to 65,535 5. Which of the following is valid identifier? A. AB@62_$ B. 7Val2 C. #answer D. Number-4 6. The ____________ is set when the result of an operation generates an unsigned value that is out of range (too big or too small for the destination operand). A. Carry flag B. Overflow flag C. Sign Flag D. Auxiliary Flag CONFIDENTIAL/2 FCVAC/IAS2123/AUG16 7. Which directive identifies the part of a program containing instructions? A. DATA B. CODE C. STACK D. PROG 8. A program is considered portable if it ____________. A. can be rewritten in a different programming language without losing its meaning B. can be quickly copied from conventional random access memory (RAM) into high-speed RAM C. can be executed on multiple platforms D. can be executed on single platforms 9. The three most basic operators in Boolean algebra are _______________. A. AND, B. OR C. NOT D. XNOT 10. Which of the following are valid data definition statements that create an array of unsigned bytes containing decimal 10, 20, and 30, named myArray. A. myArray BYTE 10, 20, 30 B. BYTE myArray 10, 20, 30 C. BYTE myArray[3]: 10, 20,30 D. myArray BYTE DUP (3) 10,20,30 11. Basic program execution registers for 32-bit is/are __________. I. AX II. BX III. EAX IV. EBX A. B. C. D. 12. I AND II I and III II and III III and IV In a statement mov EAX,10000h, identify which of the following operand is belong to EAX? A. source B. identifier C. instruction D. destination CONFIDENTIAL/3 FCVAC/IAS2123/AUG16 13. The following method must be used in computer system to represented negative integer numbers in binary format. A. Two’s complement B. Digital complement C. Hexadecimal complement D. Positive to negative complement 14. Which of the following are correct about three primary steps of the instruction execution cycle, in sequential order? A. Decode, Fetch, Execute B. Fetch, Decode, Execute C. Fetch, Decode, Memory Write D. Fetch, Memory Read, Execute PART B (40 MARKS) Answer ALL questions. Question 1 (20 marks) a) Draw a combinatorial circuits based on Boolean expression given. ((( B C ) B) (A C )) (8 marks) a) Change manually CFE + 01100111 into decimal. (4 marks) CFE to decimal = 3326 01100111 to decimal = 103 3326 + 103 = 3429 c) Form the 8-bit two's complement for 11110000. (4 marks) Starting value Reverse bits Add 1 11110000 00001111 1 00010000 CONFIDENTIAL/4 FCVAC/IAS2123/AUG16 d) Translate signed decimal numbers of -78 to binary. (4 marks) Binary representation of unsigned 78 is 01001110 Starting value Reverse bits Add 1 01001110 10110001 1 10110010 CONFIDENTIAL/5 FCVAC/IAS2123/AUG16 Question 2 (20 marks) a) Distinguish and elaborate function for three major components of CPU (Central Processing Unit). ALU (arithmetic logic unit) ◦ Performs calculations and comparisons (data changed) CU (control unit): performs fetch/execute cycle ◦ Functions: Moves data to and from CPU registers and other hardware components (no change in data) Accesses program instructions and issues commands to the ALU Registers ◦ Scratchpad for currently executing program ◦ Holds data needed quickly or frequently ◦ Stores information about status of CPU and currently executing program ◦ Address of next program instruction ◦ Signals from external devices (15 marks; 5 each) b) Describe the function for the following instruction mnemonics. Give one examples for each instruction. INC = Add 1 from destination operand; inc ebx NEG = Reverses the sign of an operand. Operand can be a register or memory operand. ; dec ecx (5 marks; 2.5 each) CONFIDENTIAL/6 FCVAC/IAS2123/AUG16 Question 3 (20 marks) Use the following variable definition for the remaining questions in this section: .data MyByte SBYTE -4,-2,3,1 MyWord WORD 1000h,2000h,3000h,4000h a) For the following statements, state whether or not the instruction is valid. Give comment to describe the reason why the instruction become valid or invalid. i) b) mov ax, MyByte = invalid ; ax for 16 bits-MyByte is 8 bits (4 marks) ii) mov ax,MyWord = valid ; ax for 16 bits-Myword is 16 bits (4 marks) What will be the value of the destination operand after each of the following instructions executes in sequence? Write appropriate comment to explain the operation executed by the instruction. i) mov ax, MyWord ; Comment : mov MyWord to ax (16 bits) ; ax =1000h (4 marks) ii) mov ax,[MyWord + 2] ; Comment: mov Myword+2 to ax (16 bits) ; ax =2000h (4 marks) iii) add ax, [MyWord + 2] ; Comment:Add value in ax(2000h) with MyWord + 2(2000h) ; ax =4000h (4 marks) CONFIDENTIAL/7 FCVAC/IAS2123/AUG16 Question 4 (10 marks) a) For the following statements, state either the instructions are valid or invalid and state the reasons: i) ii) xchg var1,var2 xchg var1,bx error: two memory operands ; exchange mem, reg (4 marks) b) State the values of the destination operand after the following instructions are executed in sequence. State the comments to explain the operations executed by the instructions as well. .data arrayW WORD 6578h,4456h,3245h arrayD DWORD 1,2,3,4 .code viii) viiii) x) mov ax,[arrayW+2] mov ax,[arrayW+4] mov eax,[arrayD+4] ; AX = 4456h ; AX = 3245h ; EAX = 00000002h (6 marks) CONFIDENTIAL/8 FCVAC/IAS2123/AUG16 PART D (30 MARKS) Answer ALL questions Question 1 a) Trace the error for the following assembly program. Rewrite and underline the correct statement. TITLE mulhexa, Version 1 (mulhexa.asm) This program adds 32-bit integers and stores the sum in a variable. Last update: 30 August 2008 INCLUDE Irvine16.inc .code num1 DWORD 32h num2 BYTE finalnum WORD 1Dh .code main PROC mov eax, num1 mul ebx, num2 mov finalnum, eax DumpRegs exit ENDP END b) ; start with 32h ; mul 1Dh ; store the result ; display the registers Trace the output for the following program. TITLE Add and Subtract, Version 2 (AddSubbinary.asm) ; This program adds and subtracts 32-bit integers ; and stores the sum in a variable. ; Last update: 06/01/2006 INCLUDE Irvine32.inc .data val1 dword 100b val2 dword 100b val3 dword 20000h val4 dword 200h finalVal dword ? .code main PROC mov add sub add mov call exit main ENDP END main eax,val1 eax,val2 eax,val3 eax,val4 finalVal,eax DumpRegs ; start with 1011b ; add 0001b ; subtract 20000h ; store the result (30000h) ; display the registers (15 marks) CONFIDENTIAL/9 FCVAC/IAS2123/AUG16 ANSWERS Trace the error for the following assembly program. Rewrite and underline the correct statement. ; TITLE mul hexa, Version 1 (mulhexa.asm) ; This program adds 32-bit integers ; and stores the sum in a variable. ; Last update: 30 August 2008 INCLUDE Irvine32.inc .data num1 DWORD 32h num2 DWORD 1Dh finalnum dWORD ? .code main PROC mov eax, num1 mov ebx, num2 mul ebx, mov finalnum, eax Call DumpRegs exit main ENDP END main ; start with 32h ; mul 1Dh ; store the result ; display the registers (10 marks; 0.5 each) b) Trace the output for the following program. (5 marks) CONFIDENTIAL/10 FCVAC/IAS2123/AUG16 Question 2 Write a complete program using MASM Assembly Language 32-bit integers with different registers. Insert the call DumpRegs statement to display the registers and flags. Apply the following arithmetic expression and data given. answer = (-val2 + val3) - val1*20d +1 +1 +1 - 1 Use the following data: val1 = 150h val2 = Ah val3 = 26d (15 marks) ANSWER ;EAX = (-val2 + val3) * val1 INCLUDE Irvine32.inc .data val1 DWORD 150h val2 DWORD 0Ah val3 DWORD 26d answer DWORD ? .code main PROC mov ebx,val2 mov ecx,val3 neg ebx add ebx,ecx mov eax,val1 mul ebx add eax,20d mov answer,eax call DumpRegs ;ebx = Ah ;ecx = 26d = 1Ah ;ebx = -Ah =FFFFFFF6h ;ebx = -Ah+1Ah =10 ;eax = 150h ;ebx =10*150 ;eax = 1500h ;display the registers exit main ENDP END main CONFIDENTIAL/11 FCVAC/IAS2123/AUG16 a) Based on the following conditions, calculate clock cycles that required to execute the instructions. Provide diagram. 15. In a 6-stage dual-pipelined processor, how many clock cycles are required to execute 5 instructions? (Assume that stage 3 requires two clock cycles, and that stage 3 has two pipelines.) (10 marks) Ans : formula =6+5 =11 =k+n 1 mark 1 mark S3 S1 S2 1 2 I-1 I-2 I-1 3 I-3 I-2 I-1 4 I-4 I-3 I-1 I-2 5 I-5 I-4 I-3 I-2 I-1 I-5 I-3 I-4 I-2 I-1 7 I-5 I-4 I-3 I-2 I-1 8 I-5 I-4 I-3 I-2 I-5 I-4 I-3 I-5 I-4 6 9 10 u v S4 S5 11 Correct cycle and stage = 1 mark S6 Full diagram = 2 mark I-5 S4 u & v = 1 mark I for u = 2 marks I for v = 2 marks CONFIDENTIAL/12 FCVAC/IAS2123/AUG16 END OF QUESTION PAPER CONFIDENTIAL/13