Question: My code fails some tests. PLEASE DONT JUST GIVE ME A CHATGPT REPLY I HAVE CHATGPT IF IT WAS GIVING ME THE ANSWER I WOULDNT
My code fails some tests. PLEASE DONT JUST GIVE ME A CHATGPT REPLY I HAVE CHATGPT IF IT WAS GIVING ME THE ANSWER I WOULDNT BE POSTING IT HERE. ALSO THIS IS AN ARMV ARMSIM DON'T USE UNSUPPORTED INSTRUCTIONS. Pretty sure what I got is good its just wrong addresses and stuff. 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. righttriangle:
SUB sp sp #
STR lrsp #
STR xsp
STR xsp #
STR xsp #
MOV x #
LDR xsp
BL pow
STR xsp #
LDR xsp #
BL pow
STR xsp #
LDR xsp #
BL pow
STR xsp #
LDR xsp #
LDR xsp #
LDR xsp #
ADD x x x
CMP x x
BEQ settrue
ADD x x x
CMP x x
BEQ settrue
ADD x x x
CMP x x
BEQ settrue
MOV x #
B done
settrue:
MOV x #
done:
LDR lrsp #
ADD sp sp #
RETtableTest,Expected,Got,table
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
