Arm/shiftu

From ASMBits

arm/addPrevious

One common case where you need to shift and truncate numbers is when converting digital audio samples between samples of different sizes, while trying to preserve most of the information about the audio sample.

For this problem, write a function (named shift) that converts one unsigned 32-bit audio sample to unsigned 8-bit format, and returns the converted sample. As a result, the least-significant 24 bits of the sample are lost (truncation). Don't do any rounding.

Expected solution length: Around 2 lines.

Sample Input

0x12345678

Sample Output

0x12

Write your solution here

x
 
1
// A test case to test your function with
2
3
.global _start
4
_start:
5
    ldr r0, =0x12345678
6
    bl shift
7
    b _start        // End of testing code
8
9
// Convert one U32 sample to U8 format
10
shift:
11
    
12
    
Upload a source file...