Question: IN ASSEMBLY Complete the code to find the sum of the series 1 +11 + 111 + 1111 + .. n terms. Your function receives
IN ASSEMBLY
Complete the code to find the sum of the series 1 +11 + 111 + 1111 + .. n terms. Your function receives n and you should move your output to the variable called sum.
Your result only needs to be 32 bits long (the max size of any of your registers), so dont worry about overflows for n>= 10. EX.: n = 2 Output = 12 (1+11) EX.: n = 3 Output = 123 (1+11+111) EX.: n = 5 Output = 12345 (1+11+111+1111+11111)
PART 1: Complete the code to find the sum of the series 1 +11 + 111 + 1111 + .. n terms. Implementation details:
The input integer n is stored in register EBX. Do not forget to move your result to the variable 'sum'.
************************************************************************************************/
unsigned int seriesSum(int n)
{
unsigned int sum=0; __asm
{ mov ebx, n
// YOUR CODE STARTS HERE
// YOUR CODE ENDS HERE
}
return sum;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
