0% found this document useful (0 votes)
24 views6 pages

ECE391 Final 21-12-2021 Answer

This document contains a final exam for a computer systems engineering course. The exam consists of 10 problems testing students' knowledge of computer architecture, assembly language programming, virtual memory, and C programming. The problems cover topics like CPU registers, memory addressing, instruction execution, function translation between C and assembly, interrupts, and memory management.

Uploaded by

Khoa Nguyễn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views6 pages

ECE391 Final 21-12-2021 Answer

This document contains a final exam for a computer systems engineering course. The exam consists of 10 problems testing students' knowledge of computer architecture, assembly language programming, virtual memory, and C programming. The problems cover topics like CPU registers, memory addressing, instruction execution, function translation between C and assembly, interrupts, and memory management.

Uploaded by

Khoa Nguyễn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Semester/Academic year 1 2021-2022

FINAL EXAM Date 21/12/2021


Course title Computer System Engineering
UNIVERSITY OF TECHNOLOGY - VNUHCM Course ID 407406
FACULTY OF EEE Duration 90 mins. Question sheet code
Student name: ID:

Notes - Students submit the question sheet together with the answer sheet
:

Problem 1: (L.O.1) (10pts) Answer the following questions

1. x86-8086 processors have:


 EAX, EBX, ECX, EDX can be accessed by 8-bit registers. True x False .
 The two main components of the CPU are the ALU and FPU True False x .
 x86 processors are big-endian True False x .
 Interrupts typically indicate error conditions internally True False x .
 Virtual memory is ensured by paging technique. True x False .

2. Suppose that you discover that RAM addresses 00125000 to 00526FFF are reserved for a PC
network adapter. How many bytes of memory is this? How many bits for this address is it?

Number of bytes of memory = 0x526FFF – 0x125000 + 1 = 0x402000 = 4 202 496 bytes


= 33 619 968 bits

Problem 2: (L.O.1) (10pts)


1. Given the data segment DS = 0x62AE.
The instruction “mov [0x2021], EAX” will store the content of EAX in which 20-bit address?

Address = 62AE:2021 = 0x62AE0 + 0x2021 = 0x64B01

2. Assume that we have the memory content as below.


Address 0x0040 0x0041 0x0042 0x0043
Content 45 7B FD 21

What are the 32-bit data when we read a double-word at the address 0x0040 with Little Endian mode?
21 FD 7B 45

Write student’s name and ID into your exam paper Page 1


Problem 3: (L.O.5) (10pts) Answer the value of registers after the instruction is executed.

No. Before Instruction After


1 BX: 3D 7E mov CX, BX BX: 3D 7E
CX: 0F 56 CX: 3D 7E
2 EAX: 45 AB E7 00 add ECX,EAX EAX: 45 AB E7 00
ECX: 01 5A C2 FE ECX: 47 06 A9 FE
SF: 0 ZF: 0 CF: 0 OF: 0
3 BX: 23 98 mov BH, DL BX: D6 98
DX: 75 D6 DX: 75 D6
4 BX: 31 0E sub BX, 12560 BX: FF FE
SF: 1 ZF: 0 CF: 1 OF: 0
5 EAX: 01 8A 08 5F imul ECX, EAX EAX: 01 8A 08 5F
ECX: 80 F9 65 48 ECX: (25E 7D) C4 B2 13 41
SF: 1 ZF: 0 CF: 1 OF: 1
6 DX: E0 15 sub DX, 168 DX: DF 6D
SF: 1 ZF: 0 CF: 0 OF: 0
7 EAX: 01 D8 6C 3A or EBX, EAX EAX: 01 D8 6C 3A
EBX: 34 21 6F 01 EBX: 35 F9 6F 3B
8 AX: 23 FE neg AX AX: DC 02
SF: 1 ZF: 0 CF: 0 OF: 0
9 EAX: 9B F8 28 CB sar EAX,4 EAX: F9 BF 82 8C
SF: ZF: 0 CF: 0 OF: 0
10 ECX: 01 FE 90 41 sal ECX, 7 ECX: FF 48 20 80
SF: 1 ZF: 0 CF: 0 OF: 0

Problem 4: (L.O.5) (10pts) Write 80x86 assembly language code for the following C procedure:
C procedure ASM procedure
Assume that S is stored in EAX, n is store in EBX
int my_func(int n) my_func:
{
int S = 1000; mov eax,1000
while (n ≠ 0) loop: comp ebx,0
{ je equal0
S--; dec eax
n = n << 1; shl ebx,1
} jmp loop
return S; equal0: ret
}

Write student’s name and ID into your exam paper Page 2


Problem 5: (L.O.5) (10pts) Write 80x86 assembly language code for the following C function.

C procedure ASM procedure


Assume that rval is stored in EAX; x, y, and z are stored in EBX,
ECX, and EDX

Unsigned int Calc(unsigned int x, Calc:


unsigned int y, unsigned int z)
{ mov eax,ebx
unsigned int t1 = x + z; add eax,edx
unsigned int t2 = 301*y; mul ecx,301
unsigned int t3 = 126*x; mul ebx,126
unsigned int t4 = t1 + t2; add eax,ecx
unsigned int rval = t4 + t3; add eax,ebx
return rval; ret
}

Problem 6: (L.O.2) (10pts) Given the Interrupt Vector Table below.

Determine the address of ISR of a device with the interrupt vector 9Ah.

Address in table = 4 x 0x9A = 02 68


(Multiply by 4 since each entry is 4 bytes)
Offset Low = [0x0268] = 10, Offset High = [0x0269] = 5A
Segment Low = [0x026A] = 38, Segment High = [0x026B] = 10
Address = 5A10:1038 = 0x5A100 + 0x1038 = 0x5b138

Write student’s name and ID into your exam paper Page 3


Problem 7: (L.O.5) (10pts) Given a function as below:

short isNumberEven (short n)


{
if (n <= 0)
return -1;
return ~(n&0x0001);
}
Rewrite this function in Assembly language (assume that n is stored in BX, the return value is stored in AX):

isNumberEven:
cmp bx,0
jle lessThanOrEqual
mov ax,bx
and ax,0x0001
not ax
ret
lessThanOrEqual:
mov ax,-1
ret

Problem 8: (L.O.5) (10pts) Describe the interrupt processing flow?

Interrupts and exceptions are events that indicate that a condition exists somewhere in the system, the
processor, or within the currently executing program or task that requires the attention of a processor. When
an interrupt is received or an exception is detected, the currently running procedure or task is suspended
while the processor executes an interrupt or exception handler. When execution of the handler is complete,
the processor resumes execution of the interrupted procedure or task. The processor receives interrupts from
two sources: External (hardware generated) interrupts. Software-generated interrupts.

Write student’s name and ID into your exam paper Page 4


Problem 9: (L.O.5) (10pts) Answer the following questions about virtual memory.

No Question Answer
.
1 Explain the need of privilege levels.

2 Explain type checking.

3 Assume that a segment has type E=1


checking: data, Read/Write, expand- W=1
down. What is type field? A=0

Problem 10: (L.O.5) (10pts) What are memory problems with the following C codes? How to solve
the problems?

No C codes What are problems? How to solve the


. problems?
1 int *my_table;
for (int i=0; i<50; i++)
*(my_table + i) = 0;

2 char *classroom = new char[10];


for (int i = 0; i < 35; i++)
{
classroom[i] = ‘A’ + i;
}

Write student’s name and ID into your exam paper Page 5


3 class student {};
student **s = new student*[100];
for (int i=0;i<100;i++)
s[i] = new student[20];

// After using s

delete[] s;

4 void error_func ()
{
int* ptr = new char(10);
return;
}
int main()
{
error_func();
return 0;
}

------------------------------------ END ------------------------------------------

Write student’s name and ID into your exam paper Page 6

You might also like