Nios/abs
From ASMBits
Write a function that returns the absolute value of its parameter. The parameter is a two's-complement signed integer.
int abs (int n);
Expected solution length: Around 4 lines.
Sample Input
10 -10
Sample Output
10 10
Write a function that returns the absolute value of its parameter. The parameter is a two's-complement signed integer.
int abs (int n);
Expected solution length: Around 4 lines.
10 -10
10 10
.global _start
_start:
movia r4, 10 # First function parameter is always passed through r4.
call abs # Return value is always in r2.
1: br 1b # Done
.global abs
abs: