Write a windows32 assembly language program that utilizes a recursive procedure.
The main (_MainProc) procedure should:
* accept, from the user, a positive integer.
* guard against non-positive integers being entered using a loop.
* call the sumseries sub-procedure using the cdecl protocol,
* receive the results of the sub-procedure, and
* display the results.
The sumseries sub-procedure should: recursively find the sum of the series:
1*2 + 2*3 + 3*4 + ... + i*(i+1) (This is an iterative definition. Change it to a recursive definition and return the value back to the main procedure)
Both main and sumseries must follow the cdecl protocol.
There are ways to do this iteratively, and to even find a closed form expression, but that is not the point of this assignment. Your program must use a recursive sub-procedure.
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
push ebx ; preserve ebx
mov ebx,[ebp + 8] ; load the number into ebx, it is on address stackpointer + 8 (stack pointer points to EBP, above is the return address of sumseries (+ 4), and above it is the parameter (+8))
cmp ebx,1 ; compare the number with 1
jne sum ; if it is not 1, then jump to sum label
mov eax,2 ; result is 2, because i = 1, result = i * (i + 1) = 1 * 2 = 2
jmp endloop ; jump to endloop label
dec ebx ; decrement the number
push ebx ; push it to stack, stack pointer decreases with 4
call sumseries ; call the procedure again, stack pointer decreases by 4 again and holds the return address
add esp, 4 ; cleanup stack, as there is no need for the parameter anymore, so stack pointer will point to return address
push ecx; preserve ecx
mov ecx, eax ; store eax (previous result) in ecx register
push ebx; preserve ebx...
This is only a preview of the solution. Please use the purchase button to see the entire solution