1.4.4. Example 1 - Sign/Zero extension

This example shows the different instructions generated when compiling for ARMv6 and earlier architectures.

signed char unpack(int i)
{
    return (signed char)i;
}

Pre-ARMv6 architecture compilations

Compiling with --cpu 5 gives:

unpack PROC
       LSL      r0,r0,#24
       ASR      r0,r0,#24
       BX       lr
       ENDP

ARMv6 architecture compilations

Compiling with --cpu 6 gives:

unpack PROC
       SXTB    r0,r0
       BX       lr
       ENDP

Copyright © 2002-2006 ARM Limited. All rights reserved.ARM DUI 0203G
Non-Confidential