Programming Assignment 3
Due: Tuesday November 2, 2004 11:59 pm
You must do the programming assignment by yourself. You are permitted to get help ONLY from the TAs and the instructor. The file you submit should be an assembly language file called triangle.asm. This is the only file you need to submit. Submission instructions are posted on the class website in the Software and Documentation section. If you are having trouble submitting, please email Danny (lynch@ece.utexas.edu) or Linda (bigelow@ece.utexas.edu).
Triangles
In this assignment, you are asked to write a program in LC-3 assembly language to determine the properties of a triangle.
Given the lengths of the three sides of the triangle you must first determine if it is possible to form a triangle with sides of these lengths.
If it is possible to form a triangle then you need to classify the triangle as follows:
Otherwise the program should behave as follows:
An equilateral triangle has sides that are all of equal length (for example 5, 5, and 5).
In this case the program should store the number #1 in memory location x3103 and output:
Equilateral
An isosceles triangle has two sides that are equal in length (for example 5, 5, and 4).
In this case the program should store the number #2 in memory location x3103 and output:
Isosceles
A scalene triangle has no sides that are the same length (for example 5, 4, and 3).
In this case the program should store the number #3 in memory location x3103 and output:
Scalene
The triangle is an obtuse triangle if a2 + b2 < c2 (for example 2, 6, 7).
In this case the program should store the number #2 in memory location x3104 and output:
Obtuse
The triangle is an acute triangle if a2 + b2 > c2 (for example 6, 6, 7).
In this case the program should store the number #3 in memory location x3104 and output:
Acute
Example 1:
If we have the following values in the following memory locations:
Location |
Contents (in hex) |
---|---|
x3100 |
x0001 |
x3101 |
x0005 |
x3102 |
x0004 |
The output should be:
Not a triangle
And the following memory locations should be:
Location |
Contents (in hex) |
---|---|
x3103 |
x0000 |
x3104 |
x0000 |
Example 2:
If we have the following values in the following memory locations:
Location |
Contents (in hex) |
---|---|
x3100 |
x0003 |
x3101 |
x0005 |
x3102 |
x0004 |
The output should be:
Scalene
Right
And the following memory locations should be:
Location |
Contents (in hex) |
---|---|
x3103 |
x0003 |
x3104 |
x0001 |
Hint 1: You can use the .STRINGZ pseudo-op to store strings in your program.
Hint 2: The ASCII code x0A causes the cursor to move to the next line.
Notes and Suggestions: