Question: ARM Assembly language. You will write a program that calculates the hypotenuse of a right triangle using Pythagorean's theorem. Prompt the user to enter two

ARM Assembly language.
You will write a program that calculates the hypotenuse of a right triangle using Pythagorean's theorem.
Prompt the user to enter two integers side A and side B of the right triangle.
If A or B is less than or equal to zero the program should prompt the user of the error and end the program.
Use the function "intSqrt" to do the square root.
You need to download the code template for this homework to work. Do not change the intSqrt.c or the tri.s file names. All code should be
written in the tri.s.
How to compile:
Unlike your previous examples the code will not compile just using gcc like it did with other examples. To compile you will run this command
make build
it will compile the intSqrt.c into an object and then compile the tri.s and intSqrt.o together to make the program work. Then to run the program
use the command
.?? tri
Submission instructions:
Submit the final version as a zip file with the following files: tri.s
Important Notes:
intSqrt wants a single parameter in rO , and will return the square root into r0
Here is the equation to find the hypotenuse c=a2+b22
ARM Assembly language.
File tri.s
.global main
.extern intSqrt //DO NOT REMOVE
.align 4
.section .data
// your data here
.align 4
.section .rodata
// your read only data here
.text
main:
push {lr}
// this is dummy code to show you how to use the intSqrt function
// you can erase this and put your code here
mov r0, #4
bl intSqrt // Call a square root routine
pop {pc}// should return 2 if the sqrt is working
File intsqrt.c
#include
#include
uint32_t intSqrt( uint32_t a ){
return (uint32_t) sqrt((double) a );
}
File Makefile
build:
gcc -c intSqrt.c -o intSqrt.o
gcc -o tri intSqrt.o tri.s -lm
clean:
rm tri sqrt.o
ARM Assembly language. You will write a program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!