Arm/shifts

From ASMBits

arm/shiftuPrevious

One common case where you need to shift and truncate numbers is when changing the amplitude of audio samples.

For this problem, write a function (named shift) that will accept a 32-bit signed audio sample, and return a 32-bit signed audio sample with 1/4 of the amplitude. Don't do any rounding (just shift and truncate).

Expected solution length: Around 2 lines.

Sample Input

0x40000

Sample Output

0x10000

Write your solution here

x
 
1
// A test case to test your function with
2
3
.global _start
4
_start:
5
    ldr r0, =0x40000
6
    bl shift
7
    b _start        // End of testing code
8
9
// Return 1/4 amplitude for a S32 sample
10
shift:
11
    
12
    
Upload a source file...