Philadelphia University Student Name: Faculty of Engineering Student Number: Dept. of Computer Engineering Final Exam, Second Semester: 2013/2014 Course Title: Microprocessors Date: 08/06/2014 Course No: 0630313 Time Allowed: 2 Hours Lecturer: Dr. Qadri Hamarsheh No. Of Pages: 7 Information for Candidates 1.This examination paper contains 6 questions totaling 40 marks. 2.The marks for the questions are : Question 1 (10 marks), Question 2 (8 marks), Question 3 (6 marks) Question 4 (5marks), Question 5 (5 marks), Question 6 (6 marks) Advice to Candidates 1. You should attempt ALL requested parts. 2. You should write your answers clearly. Basic notions: The aim of the questions in this part is to evaluate the required minimal student knowledge and skills. Answers in the pass category represent the minimum understanding of IA-32 Processor Architecture, Assembly Language Fundamentals: Instructions, Directives, Identifiers, Defining Data, Symbolic Constants, Data Transfers, Addressing, and Arithmetic instructions Addressing Modes, Conditional and Unconditional instructions, Stack, Pointers, Arrays and Procedures. Question 1 Multiple Choices (10 marks) Identify the choice that best completes the statement or answers the question. 1) Since the x86 has an address bus of 20-bits, its memory is segmented into 1 M segments (i.e. 2 20 ). a) True b) False 2) If CS = 7FA2H, SS = 0801H, SI = 0100H and IP = 438EH the address of the next instruction is: a) 83DAEH b) 438EH c) 83DA0H d) None of the above 3) One of the following is not a valid segment address a) 00000 b) E0840 c) 8CE90 d) 8CE91 4) Pipelining improves CPU performance due to a) increased clock speed b) the introduction of parallelism c) reduced memory access time d) additional functional units 5) The basic parts of an instruction, in order from left to right, are: a) label, mnemonic, operand(s), comment b) comment, label, mnemonic, operand(s) c) label, mnemonic, comment d) mnemonic, operand(s), comment 6) Which of the following will generate assembly errors? a) var1 BYTE 1101b, 22, 35 b) var3 BYTE '$','98778', c) var2 BYTE "ABCDE", 18 d) None of the above 7) Which directive is used when defining BCD numbers? a) DWORD b) FWORD c) QWORD d) TBYTE 8) Given that the BL register contains B, the effect of the following instruction OR BL, 0010 0000 is to a) clear BL b) store 0010 0000 in BL c) store b in BL d) leave BL unchanged 1
9) What is the result in AL after executing the following instructions? XOR AL, AL OR AL, 80H a) 80H b) 88H c) 00H d) None of the above 10) Which of the following are performed when an interrupt occurs: (I) FLAGS register is pushed to the stack (II) CS register is pushed to the stack (III) IP register is pushed to the stack a) (I) and (II) and (III) b) (I) and (II) only c) (II) and (III) only d) (I) and (III) only Question 2 (8 marks) a) Design and draw the block diagram for a hypothetical ALU (Arithmetic and logic Unit) having 4 arithmetic operations and 4 logical operations. (3 marks) Four arithmetic operations. Addition, subtraction, multiplication and division. Four logical operations: OR, AND, NOT & XOR. b) Explain the purpose of the TYPEDEF statement. Give the syntax and examples of its use. 2
c) Mention how do the following instructions differ in their functionality. NEG & NOT AND & TEST CMP & SUB d) Explain the various hardware and software interrupts in 8086 microprocessor. (2 marks) Familiar and Unfamiliar problems solving: the aim of the questions in this part is to evaluate that the student has some basic knowledge of the key aspects of the lecture material and can attempt to solve familiar and unfamiliar problems of Assembly Language Fundamentals: Instructions, Directives, Identifiers, Defining Data, Symbolic Constants, Data Transfers, Addressing, and Arithmetic instructions Addressing Modes, Conditional and Unconditional instructions, Stack, Pointers, Arrays and Procedures. Question 3 (6 marks) a) Fill in the contents of the specified registers in the following code as hex-digit numbers:.data DWORD 5 L DWORD 2,3,4 DWORD 6.code MOV EAX,L-4 ; EAX=---------------- MOV EBX,L+4 ; EBX=---------------- MOV ECX,L+12 ; ECX=---------------- 3
b) Consider the following Boolean expression: if (J <= K) then L := L + 1 else L := L - 1 Write an assembly language code to implement the above expression. Assume that all variables are declared and of type SWORD. c) Consider the following Boolean expression: while (j >= k) do begin j := j - 1; k := k + 1; end; Write an assembly language code to implement the above expression. Assume that all variables are declared and of type WORD. d) The array C of 100 bytes is assumed to contain string of ASCII characters. Write an assembly language code to Check if it contains the '$' character and go to location HasDollar if it does. 4
Question 4 (5 marks) Write a complete assembly language program that should: a) Declare array Uarray of four values of data type WORD, initialize values to 1000h, 2000h, 3000h, 4000h respectively. b) Declare array Sarray of four values of data type SWORD, initialize values to FFFFh, FFFEh, FFFDh, FFFCh respectively. c) Write instructions that use direct-offset addressing to move the four values in Uarray to the EAX, EBX, ECX, and EDX registers. When you follow this with a call DumpRegs statement, the following register values should display: EAX=00001000 EBX=00002000 ECX=00003000 EDX=00004000 d) Next, write instructions that use direct-offset addressing to move the four values in Sarray to the EAX, EBX, ECX, and EDX registers. When you follow this with a call DumpRegs statement, the following register values should display: EAX=FFFFFFFF EBX=FFFFFFFE ECX=FFFFFFFD EDX=FFFFFFFC 5
Question 5 (5marks) Write a program that generates and displays 50 random integers between -20 and +20. 6
Question 6 (6 marks) Write an assembly language program (complete) that Reads two strings of 200 characters maximum from the keyboard using Irvine32 Library. Exits from a program if the length of the two strings is different. Encrypts the first string using the second string as a key. Uses suitable I/O Messages for data entry. Good Luck 7