Nios/sum args20

From ASMBits

Write a function with 20 arguments that returns the sum of all of its arguments. The function will be called with exactly 20 arguments.

Return the sum of all 20 numbers. Overflowing a 32-bit register should wrap around (i.e., no special handling).

Push the four register parameters onto the stack in the function prologue, then iterate over the parameters (now stored consecutively on the stack) in a loop. We'll check your stack frame to ensure you did this. (This will be particularly useful for functions with variable arguments, e.g., nios/sum_args)

int sum(int n1, int n2, int n3, ... , int n20);


Expected solution length: Around 15 lines.

Sample Input

sum(1, 2, 3, ... , 20)

Sample Output

 210 

Write your solution here

Upload a source file...