1.4.5. Example 2 - instructions generated for packed structures

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

__packed struct{
    char ch;
    short sh;
    int i;
} foo;

signed char unpack()
{
    return (signed char)foo.i;
}

Pre-ARMv6 architecture compilations

Compiling with --cpu 5 gives:

unpack PROC
       STMFD    sp!,{r3,lr}
       LDR      r0,|L1.24|
       BL       __rt_uread4
       MOV      r0,r0,LSL #24
       MOV      r0,r0,ASR #24
       LDMFD    sp!,{r3,pc}
       |L1.24|
       DCD      ||.bss$2|| + 3
       ENDP

ARMv6 architecture compilations

Compiling with --cpu 6 gives:

unpack PROC
       LDR      r0,|L1.16|
       LDR      r0,[r0,#3]
       SEXT8     r0,r0
       BX       lr
       |L1.16|
       DCD      ||.bss$2||
       ENDP

Copyright © 2002-2005 ARM Limited. All rights reserved.ARM DUI 0203F
Non-Confidential