Philadelphia University Faculty of Engineering Marking Scheme Examination Paper Department of CE Module: Microprocessors (630313) Final Exam Second Semester Date: 12/06/2017 Section 1 Weighting 40% of the module total Lecturer: Coordinator: Internal Examiner: Dr. Qadri Hamarsheh Dr. Qadri Hamarsheh Eng. Anis Nazer
Marking Scheme Microprocessors (630313) The presented exam questions are organized to overcome course material, the exam contains 5 questions; all questions are compulsory requested to be answered. Thus, the student is permitted to answer any question out of the existing ones in this section. Marking Assignments The following scheme shows the marks assignments for each question. They show also the steps for which a student can get marks along the related procedure he/she achieves. Question 1This question is attributed with 10 marks if answered properly 1) The 8086/8088 used two processing logical units which were known as: a) Segment and Offset Units b) Bus Interface Unit and Execution Unit c) Bus Unit and Execution Interface Unit d) ALU and Control Unit 2) What are the names of the 4 segment registers? a) Data, Index, Code, Stack b) Stack, Index, Extra, Code c) Stack, Extra, Code, Data d) Stack, Data, Base, Counter 3) Memory segmentation (partitioning) was necessary because the x86 registers were 16-bits and could not hold the 20-bit addresses of the main memory a) True b) False 4) In the following data definition, assume that List2 begins at offset 2000h. What is the offset of the third value (5)? List2 WORD 3, 4, 5, 6, 7 a) 2006h c) 2004h b) 2003h d) None of above 5) Which of the following is an invalid instruction? a) MOV AX, [BP] c) MOV AX, CS b) MOV DS, CS d) None of the above 6) Assume the following initial state for AX, BX, CX registers: AX 6521 H BX ABCD H CX 0105 H What are the flags after CMP AH, CL a) C=1, Z=0, S=1 c) C=0, Z=1, S=1 b) C=0, Z=1, S=0 d) C=0, Z=0, S=0 7) Given that the BL register contains b, the effect of the following instruction and BL, 1101 1111 is to a) clear bl c) store B in bl b) store 0010 0000 in bl d) leave bl unchanged 8) Given that the subprogram WriteChar displays the character in AL register, the effect of the following instructions: mov AL, c sub AL, 2 call WriteChar is to a) display 2 c) display 'c' b) display 'a' d) display a blank
9) The interrupt vector table (IVT) is located at addresses: a) 00000H 01024H c) 00000H 003FFH b) 00000H 000FFH d) FFF00H - FFFFFH 10) INT 21 service 01H is used to read character from standard input with echo. It returns the result in register. a) AL c) BH b) BL d) CL Question 2 This question is attributed with 9 marks if answered properly Question 2 (9 marks) a) Explain 8086 flag register? (2.5 marks) 1. Carry Flag (CF) - this flag is set to 1 when there is an unsigned overflow. For example when you add bytes 255 + 1 (result is not in range 0...255). When there is no overflow this flag is set to 0. 2. Parity Flag (PF) - this flag is set to 1 when there is even number of one bits in result, and to 0 when there is odd number of one bits. 3. Auxiliary Flag (AF) - set to 1 when there is an unsigned overflow for low nibble (4 bits). 4. Zero Flag (ZF) - set to 1 when result is zero. For non-zero result this flag is set to 0. 5. Sign Flag (SF) - set to 1 when result is negative. When result is positive it is set to 0. (This flag takes the value of the most significant bit.) 6. Trap Flag (TF) - Used for on-chip debugging. 7. Interrupt enable Flag (IF) - when this flag is set to 1 CPU reacts to interrupts from external devices. 8. Direction Flag (DF) - this flag is used by some instructions to process data chains, when this flag is set to 0 - the processing is done forward, when this flag is set to 1 the processing is done backward. 9. Overflow Flag (OF) - set to 1 when there is a signed overflow. For example, when you add bytes 100 + 50 (result is not in range -128...127). b) Fill the following table that describes data-related operators and directives used in assembly language. (3 marks) Operator Usage and Description OFFSET Return the distance of variable from the start of segment. PTR Allows for override of variable's default size. TYPE Returns the size (in bytes) of an operand or each piece of an array. LENGTHOF Returns number of elements in an array. SIZEOF Returns number of bytes used by an array initializer (same as LENGTHOF * TYPE). Provides a way to redefine the same variable with different size LABEL attributes (Provide an alternate size for a variable without using PTR). c) What is the use of Interrupt vector table of 8086 microprocessor and describe the IVT Format? (2 marks) The interrupt vector table contains 256 four byte entries, containing the CS:IP interrupt vectors for each of the 256 possible interrupts. The table is used to locate the interrupt service routine addresses for each of those interrupts using the following equation:
d) Explain the following instructions: (1.5 marks) NEG LOOP SAHF NEG: Arithmetic sign inversion or two s complement (NEG). The NEG instruction two s complements a number, which means that the arithmetic sign of a signed number changes from positive to negative or from negative to positive. LOOP: (Jump to specified label until CX = 0) this is used to repeat a sequence of instructions for the specified number of times. The number of times the specified sequence is to be repeated is stored in CX register. No flags are affected. SAHF: (Store AH register into flag register) It is an instruction used to store the data in the AH register into the lower eight bits of the flag register. Question 3 This question is attributed with 8 marks if answered properly Question 3.a (2.5 marks) This is a trick! The program does not stop, because the first loop instruction decrements EAX to zero.the second LOOP instruction decrements EAX to FFFFFFFFh, causing the outer loop to repeat. Question 3.b (3.5 marks) Task mark 1. Invert the seventh bit in DX (note: the LSB XOR DX, 40H 0.5 mark is the first bit) 2. Set the 5 th and the 11 th bits in AX OR AX, 410H 0.5 mark 3. Calculate the 2's complement of AX NOT AX 0.5 mark INC AX 4. Jump to label 'HELP' if AX is even TEST AX, 01H JZ HELP 0.5 mark 5. Three different instructions that will subtract 1 from register DX Question 3.c AX =2010h EAX =003b008ah AX =0 AX =0044h 1) DEC DX 2) ADD DX, -1 3) SUB DX, 1 1.5 marks (2 marks)
Question 4 This question is attributed with 6 marks. The complete code for this question as the following: TITLE (StackApplications.asm).Model Flat, stdcall.stack 1024 INCLUDE.Data.Code END Irvine32.inc Array1 DWORD 44h, FFh, 555, 11 Msg Byte " Assembly language is easy ",0 (2 mark) Main PROC push esi ; push registers push ecx push ebx mov esi,offset Array1; mov ecx,lengthof Array1 mov ebx,type Array1 call DumpMem mov esi,offset Msg; mov ecx,lengthof Msg mov ebx,type Msg call DumpMem pop ebx ; restore registers pop ecx pop esi exit Main ENDP Main Question 5 This question is attributed with 7 marks. Title CompareStrings.asm.Model small.stack 1024 Include.Data.Code Main PROC mov Irvine16.inc Src Byte First Strnig 1, 0 LSrc EQU $- Src Dst Byte First Strnig 2, 0 Equal Byte EQUAL, 0 Non_Eq Byte NOT EQUAL, 0 (2 marks) AX, @Data mov DS, AX mov SI, Offset Src mov DI, Offset Dst mov CX, LSrc (2 mark) Again: mov AL, [SI] cmp AL. [DI] je Next_Cmp mov DX,Offset Non_Eq jmp Output Next_Cmp: inc SI inc DI loop Again mov DX,Offset Equal Output: call WriteString Exit Main ENDP END Main (3 marks)