Arm/abs

From ASMBits

arm/oddPrevious

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 3 lines.

Sample Input

10
-10

Sample Output

10
10

ARM does have a negation instruction, but it is oddly named: reverse subtract from #0. There is also a less oddly-named alias called neg.

Write your solution here

Upload a source file...