Nios/odd

From ASMBits

nios/invertPrevious

Write a function that returns the whether its parameter is odd. Return 1 if odd, 0 if even. Your algorithm's runtime should not grow with the value of n because there is a runtime limit on your function of 10000 instructions.

int odd (int n);

Expected solution length: Around 2 lines.

Sample Input

1
2

Sample Output

1
0

Write your solution here

x
 
1
.global _start
2
_start:
3
    movia r4, 1    # First function parameter is always passed through r4.
4
    call odd       # Return value is always in r2.
5
    1: br 1b    # Done
6
7
.global odd
8
odd:
9
    
10
    
Upload a source file...