Nios/bits1

From ASMBits

An unsigned number of n bits can represent values between 0 and 2n-1, inclusive. Write a function that returns how many bits are needed to represent a given number, in unsigned binary representation.

unsigned int bits(unsigned int num);


Expected solution length: Around 10 lines.

Sample Input

0x1000

Sample Output

r2=13

Write your solution here

x
 
1
# A test case to test your function with
2
.global _start
3
_start:
4
    movia r4, 0x1000
5
    call bits
6
    br _start        # End of testing code
7
8
# Return minimum number of bits to represent first parameter
9
bits:
10
    
11
    
Upload a source file...