Mpfe 20182 1
Mpfe 20182 1
Student Number:
Faculty of Engineering Serial Number:
Instructions:
ALLOWED: pens and drawing tools (no red color).
NOT ALLOWED: Papers, calculators, literatures and any handouts. Otherwise, it will lead to the non-approval of your
examination.
Shut down Telephones, and other communication devices.
Please note:
This exam paper contains 5 questions totaling 40 marks.
Write your name and your matriculation number on every page of the solution sheets.
All solutions together with solution methods (explanatory statement) must be inserted in the labelled position on the
solution sheets.
You can submit your exam after the first hour.
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, Interrupts, Arrays and Procedures.
5) In the following data definition, assume that X2 begins at offset 4000h. What is the offset of the third
value (66)?
X2 DWORD 37, 49, 51, 66, 77
a) 4004h b) 4008
c) 400A d) 400C
1
6) _____________ can be used as indexed registers in real addressing mode.
a) BX, SI, DI
b) SI, DI, , DS
c) AX, SI, DI
d) AX, BX, CX
8) From hardware viewpoint, the overflow flag (OF) can be implemented using the following logic
expression:
a) OF = CF AND MSB
b) OF = CF OR MSB
c) OF = CF XOR MSB
d) None of the above
9) Assume that the AX register contains the value 6521 H. What will be the contents of AX after execution
the instruction:
CMP AL, AH
a) 65BC H b) BC21 H
c) 4421 H d) 6521 H
2
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, Interrupts, Arrays
and Procedures.
Question 2 (10 marks)
a) Explain the following terms: (1.5 marks)
Term Description
Virtual memory:
Real mode
Protected mode
3
c) Explain Memory Models that can be used in assembly language. (3.5 marks)
Solution
4
Question 3 (10 marks)
Ñ Instruction Answer
b) Where indicated, write down the values of the Carry, Sign, Zero, and Overflow flags after each
instruction has executed: (2 marks)
mov ax, 7FF0h
add AL, 10h ; CF = -------- SF = -------- ZF = -------- OF = --------
5
d) What will be the final value stored in memory (SUM) after the execution of the following assembly
code (2 marks)
.DATA
NUMBERS SByte 3, -1, 4, 2, 5, 9, -2, -7
SUM SByte ?
.CODE
.STARTUP
MOV SI, OFFSET NUMBERS
MOV AX, 0H
MOV CX, 4
L1:
MOV BL, [SI]
ADD AL, BL
ADD SI, 2
LOOP L1
MOV SUM, AL
Solution
6
Question 4 (4 marks)
Write a complete assembly program that computes the following equations
In your code:
Declare the following uninitialized variables:
2-byte signed integers: Y, X1, X2 .
2-byte unsigned integers: Z, X3, X4.
Declare the constant symbolic C and assign it the value 200.
In code section, assign variables X1=FFh, X2=-10, X3=555, X4 =100
Compute and .
Assume that real Addressing-mode is used.
Use one segment for both code and data sections.
Solution
7
Question 5 (6 marks)
Write an Assembly Language program to compare two strings and display if they are equal.
The program should:
Enter two strings (100 characters for each string) from keyboard.
Display the message "Strings are equal" when the strings are equal and the message "Strings
are not equals" otherwise.
Use Protected Mode Programming.
Use Indirect Addressing Mode.
Use Irvine32 library for input and output.
Solution
Good Luck
8