Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a complete program that includes a subroutine called GCD to compute the greatest common divisor ( GCD ) of two numbers a and b
Write a complete program that includes a subroutine called GCD to compute the greatest common divisor GCD of two numbers a and b
The subroutine will accept two inputs and return the result on the RTS Use the following algorithm to compute the GCDab
Algorithm : GCD Algorithm
Input : where
Output:
while do
while do
clarra
alarrc
end
while do
clarrb
blarrc
end
end
return
Include a main program to test your subroutine. Try testing with values store these using labels with the same name You can put
your test values in memory locations given by labels a b When the subroutine returns, your program should extract the result and store it at
the memory location given by label result. You may use the following template for your program.
;Implements a subroutine to compute GCD
orig
main
LD R stackbase
;set up RTS
; put your code for the mainline here
HALT
a fill ;change a and to test your program with different values
b fill
result blkw
stackbase fill ex
GCD
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