Nios/mask2

From ASMBits

nios/maskPrevious

A 32-bit binary number contains 32 binary digits, each of which is 0 or 1. Write a function that will return a 32-bit number where bits M (inclusive) to N (exclusive) are 1 (bits are numbered from 0 to 31).

N and M are between 0 and 32. N is guaranteed to be no smaller than M. If N == M, then no bits are set to 1. The special case where M == 0 is equivalent to the previous problem (mask)

unsigned int mask(unsigned int N, unsigned int M);

Expected solution length: Around 6 lines.

Sample Input

mask(4, 2)

Sample Output

r2=0xc

Write your solution here

Upload a source file...