Question
write less than 10 lines of codes in assembly. The first function, write assembly code to compute the area of a right triangle: 1/2*a*b where
write less than 10 lines of codes in assembly.
The first function, write assembly code to compute the area of a right triangle: 1/2*a*b where a and b are the two legs of the triangle. Use integer arithmetic and don't worry about truncation by division. I will be using even values for a and b. Also, you will get only 35 points if you use the idiv instruction and a full 50 points if you avoid it.
*This must be in assembly. Do not write any C code. *This should be less than 10 lines long including any input and output. Writing more than this will reduce the number of points.
// These can be changed for debugging purposes // but DO CHANGE THEM TO THE ORIGINAL VALUES // RUNS = 10000 // SIZE = 10000 #define RUNS 10000 #define SIZE 10000
/* write a function using gcc inline assembly * that calculates the area of a right triangle. * the formula for doing so is: * area = 1/2 x side1 x side2 */
// This is the function.
int calcArea(int side1, int side2) { int area = 1.0;
// PUT YOUR ASSEMBLY CODE HERE // DON'T WRITE ANY OTHER // C CODE return area; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started