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 X and X the "pow" procedure will calculate XX and leave the result in X
Write a procedure with label "righttriangle" that will determine if the values in X X and X 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 X if it is not a triangle, and X if it is
Note: you may not assume X holds the longest side!
Warning: pow will zero all registers except X 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 nonzero registers through x Remove any calls to debug: for final submission. heres my code. it dont work: righttriangle:
MOV X #
MOV X X
BL pow
MOV X X
MOV X X
BL pow
MOV X X
MOV X X
BL pow
MOV X X
ADD X X X
CMP X X
BEQ found
ADD X X X
CMP X X
BEQ found
ADD X X X
CMP X X
BEQ found
MOV X #
B exit
found:
MOV X #
exit:
RET
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
