CSE341 Project1 Solved

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

Rate this product

You are required to write simple programs in assembly language in this project. The programs are supposed to perform the following tasks.

Task 1: Calculator

Requirement: You are asked to implement a simple calculator including addition, subtraction, multiplication and division. This calculator only considers integer arithmetic, i.e. the inputs and outputs are integers only. Negative integers should be considered.

For indivisible cases in division operation (e.g., 4/5), only the integer quotient needs to be returned, while the remainder (decimal) part can be dropped.

Task 2: Hamming Distance

Background Hamming distance measures the minimum number of substitutions required to change one string into the other, or the minimum number of errors that could have transformed one string into the other. For example, the distance between 5068 and 5098 is one, and the distance between 2345 and 2333 is two.

Requirement You are asked to implement code to calculate Hamming distance between two numbers with only two digits (e.g. 11 and 16). This can be done by treating the integers as string and comparing each pair of characters (with the same index). Don’t include negative integers.

Task 3: Euclidean Distance

Background Euclidean distance defines the distance between two points in Euclidean space. When considering a one-dimension Euclidean space, the distance between 𝑥 and 𝑦 could be given by:

𝑦|

For a two-dimension Euclidean space, if

𝒙 = (𝑥1, 𝑥2), 𝒚 = (𝑦1, 𝑦2), The distance is given by:

𝑑(𝒙, 𝒚) = √(𝑥1 − 𝑦1)2 + (𝑥2 − 𝑦2)2

Requirement You are asked to calculate Euclidean distance in a two-dimension Euclidean space. An easy way to do this is using the sqrt instruction, sqrt.s or sqrt.d, corresponding to single and double precision respectively. Single precision should be enough for this project anyway.

 

1.   Requirements & General Issues to be Considered

a). Input and output

Inputs of all the 3 tasks are integers only, no need to consider floating point inputs. All input numbers should be read from the console, and the results printed back to the console, otherwise you cannot be graded. Here is an example of the console for calculator:

input first num: 30 input second num: 15

input operation (1 4, 1:+, 2:-, 3:×, 4:÷): 3

 

result is: 450

 

b). Handling overflow or extremely large numbers

We assume all the inputs and results can be fitted into one register, therefore, for the sake of our project, there is NO NEED to handle extremely large numbers or any overflow they may cause. c). Handling invalid input or exception

You DO NOT need to differentiate and take care of all the possible situations. But at least this error checking should work as the safeguard to make sure the program won’t break or be stuck in deadlock if there are any “abnormal” inputs. Also, your program is supposed to go back to the very beginning (where it asks for inputs and types of operation) after each computation.

E.g., when the given operation code is something like 5 (which does not correspond to +, -, × or ÷), the program should be able to ignore the case and go back to the beginning. d). Using sqrt instruction The syntax goes like:

sqrt.s  $dst_register, $operand

 

In order to use it, you can either 1) use cvt.s.w to convert the integer to single first, or 2) use single precision format (enough for this project) for the other calculations (say add.s, mul.s) to get the number to be sqrt on. In addition, make sure to use floating-point registers $f0 ~ $f31 to store the floating-point result.

 

  • project-g4i1dx.zip