Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The sum the numbers between 0 and n is the nth triangle number tri( n ). Triangle numbers can be calculated recursively via tri( n
The sum the numbers between 0 and n is the nth triangle number tri(n). Triangle numbers can be calculated recursively via tri(n) = tri(n-1) + n. Modify the code shown bellow so that it now has a main that simply calls a RECURSIVE triangle function with a single parameter of 12 (that is retrieved from a memory labeled trinput). This function will return the 12th triangle value and the main will then store only this one value back into memory in a memory location labeled trinumber. This recursive function implements the loop construction. Triangle will have to save at least one parameter to the runtime stack in addition to the return addresses. The code: /* -- first.s */ /* This is a comment */ .global _start @ declare entry point _start: @ label for the entry point mov r0, #2 @ Put a 2 in r0 mov r7, #1 @ setup system call to exit swi 0 @ system call to exit
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