程序代写代做代考 assembly XJTLU 1/2 Computer Systems

XJTLU 1/2 Computer Systems
1. To do
Practical Exercise 4 (assessed)
Implement an inline assembly program which does the following. It asks repeatedly a user to enter his/her data from a mobile device, such as:
 Enter the current reading: …
 Enter the current reading: …
 Enter the current reading: …
After all the readings are entered the smallest number, second smallest number, median, second largest number, and largest number will then be computed and printed out. Please note: the median is the value separating the higher half of a data sample, from the lower half.
Example 1: assume the following values were read 3, 7, 2, 0, 1, 4, 3, 6, 7, 9, 8. Then the smallest is 0, the second smallest is 1, the median is 4, the second largest number is 8, while the largest is 9.
Example 2: assume the following values were read -3, 7, -2, 3, 0, 1, 4, 3, 6, 7, 9, 8. Then the smallest is -3, the second smallest is -2, the median is 3+4/2 = 3.5, the second largest number is 8, while the largest is 9.
2. Learning outcome
1. Tounderstandthecomponentsofacomputersystem,theirfunctionsandinteractions 2. Todevelopfurtherinlineassemblyprogrammingskills
3. Requirements
You should assume the device reading to be an integer in the range [-15, 15]. If the reading is outside the range it should not be accepted and the request should be repeated. However, your program should be able to proceed and output correct results even in the presence of erroneous inputs, e.g.
 Any input reading is out of the range [-15, 15].
The readings should be stored in an array. Sample programs that handle arrays are enclosed below.
4. Sample programs 4.1. Array handling 1
/* Handling arrays with Register Indirect addressing mode */ ……
// declaration of an array of integers = 1; //
= 3; //
lea ebx,myarray //addressofthearray(its0thelement)issavedinebx mov ecx,5 // size of the array is saved in the counter
int myarray[5];
myarray[0]
myarray[1]
myarray[2]
myarray[3]
myarray[4]
_asm {
// initialise the array
= 5;
= 7; // = 9; //

XJTLU 2/2 Computer Systems
mov Loop1:
add
eax,0 // eax will be used to store the sum, initialise to 0
add eax,[ebx] //read an element of the array at the address stored in ebx
ebx,4 //int occupies 4 bytes (32 bits),
//so to read next element increase an address in ebx by 4
loop Loop1 // the end of the loop
… }
4.2. Array handling 2
/* Handling arrays with Register Indirect with Displacement addressing mode */
// declaration of an array of integers and initialisation are as above

_asm {
mov ecx,5 // size of the array is saved in the counter
mov eax,0 // eax will be used to store the sum, initialise to 0
mov ebx,0
Loop1: add eax,myarray[ebx] // read an element of the array at the address myarray+ebx
add ebx,4 // int occupies 4 bytes (32 bits), so to read next element increase an address in ebx // by 4
loop Loop1 // the end of the loop
… }
5. Assessment
This exercise will be assessed during the due date by your TAs or demonstrators. You will demo the following: a. your program can compile and run, b. your program generates the output correctly, c. your knowledge of the program THAT IS WRITTEN BY YOU.
What to do during the assessment upon the due date?
a. Sign for attendance at the pre-scheduled assessment timeslot.
b. Demonstrate and explain to the lab demonstrator that your program works for the problem assigned.
c. Hand in a well-commented, stapled program listing with the module title and your name/student number shown on the
title page. Your program listing should not exceed 6 pages. You should also sign and declare non-plagiarism.
6. Deadline
13-15pm, 12th December 2016 at Lab 546.