Question: Assume a procedure with the label pow: has been defined elsewhere. With positive integer values in X 0 and X 1 , the pow procedure

Assume a procedure with the label "pow:" has been defined elsewhere. With positive integer values in X0 and X1, the "pow" procedure will calculate X0X1, and leave the result in X7.
Write a procedure with label "right_triangle" that will determine if the values in X0, X1, and X2 form the sides of a right triangle (think Pythagorean Theorem, and you must use pow to compute the squares of the sides). On return, set X0==0 if it is not a triangle, and X0==1 if it is.
Note: you may not assume X2 holds the longest side!
Warning: pow will zero all registers except X7, so you'd better to store relevant values on the stack!
For convenience of debugging, a procedure labeled "debug:" has been defined which will print the values of all non-zero registers (through x29). Remove any calls to debug: for final submission. heres my code. it dont work: right_triangle:
MOV X1, #2
MOV X0, X0
BL pow
MOV X3, X7
MOV X0, X1
BL pow
MOV X4, X7
MOV X0, X2
BL pow
MOV X5, X7
ADD X6, X3, X4
CMP X6, X5
BEQ found
ADD X6, X3, X5
CMP X6, X4
BEQ found
ADD X6, X4, X5
CMP X6, X3
BEQ found
MOV X0, #0
B exit
found:
MOV X0, #1
exit:
RET
Assume a procedure with the label "pow:" has been

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!