Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 ) Recursion Write an assembly function dumb ( a , b ) that takes two unsigned integer arguments and implements this recursive calculation (
Recursion
Write an assembly function dumba b that takes two unsigned integer arguments and implements this recursive calculation thats called "dumb" because it does a dumb calculation that makes no sense, but that's the task:
def dumba b:
if a :
return b
elif b :
return a
else:
return a a b dumba b
You must use the stack to store the a and b values across the recursive call.
pass these tests:
printfdumbli
dumb;
printfdumbli
dumb;
printfdumbli
dumb;
printfdumbli
dumb;
Unsigned Overflow
Write an assembly function largestpowerunsigned that takes an unsigned integer as its argument and returns the largest power of that number that's representable as a bit unsigned integer.
In order to find that value, you need to repeatedly multiply by
until you see an unsigned overflow and return the value before you saw the overflow.
The value you return p
should be a power of n
so ni p
for some i
such that p
and np
But you can't detect it with math: you need to calculate and watch the carry flag.
so it passes the tests:
printflargestpowerunsignedlu
largestpowerunsigned;
printflargestpowerunsignedlu
largestpowerunsigned;
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