Arm/extend
From ASMBits
arm/signextPrevious
Nextarm/saturate
Write a function (named extend) that will extend a number to 32 bits and return the extended number (in r0). The first function parameter (in r0) specifies which operation to do, while the second parameter holds the number to extend:
- r0 = 0: Zero extend 8 bit to 32 bit
- r0 = 1: Zero extend 16 bit to 32 bit
- r0 = 2: Sign extend 8 bit to 32 bit
- r0 = 3: Sign extend 16 bit to 32 bit
int extend(int operation, int n);
Sample Input
extend(2,0xf0)
Sample Output
r0=0xfffffff0
arm/signextPrevious
Nextarm/saturate