## Nios/extend

### From ASMBits

Write a function (named extend) that will extend a number to 32 bits and return the extended number (in r2). The first function parameter (in r4) specifies which operation to do, while the second parameter holds the number to extend:

• r4 = 0: Zero extend 8 bit to 32 bit
• r4 = 1: Zero extend 16 bit to 32 bit
• r4 = 2: Sign extend 8 bit to 32 bit
• r4 = 3: Sign extend 16 bit to 32 bit
```int extend(int operation, int n);
```

#### Sample Input

`extend(2,0xf0)`

#### Sample Output

`r2=0xfffffff0`