Question: My code has errors. Assume a procedure with the label pow: has been defined elsewhere. With positive integer values in X 0 and X 1
My code has errors. 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. tableTest,Expected,Got,tablerighttriangle:
SUB sp sp #
STR xsp
STR xsp #
STR xsp #
STR lrsp #
MOV x #
LDR xsp
BL pow
MOV x x
LDR xsp #
BL pow
MOV x x
LDR xsp #
BL pow
MOV x x
LDR lrsp #
ADD x x x
CMP x x
BEQ isright
ADD x x x
CMP x x
BEQ isright
ADD x x x
CMP x x
BEQ isright
MOV x #
B done
isright:
MOV x #
done:
LDR lrsp #
ADD sp sp #
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
