/*
typedef struct
{
_u8 a;
_u32 b;
_u8 c;
_u16 d;
_u32 e;
float f;
}test_t;
static test_t tmp_struct;
tmp_struct.a = 1;
tmp_struct.b = 2;
tmp_struct.c = 3;
tmp_struct.d = 4;
tmp_struct.e = 5;
tmp_struct.f = 1.2;
通过汇编取指访问结构体成员变量得知:结构体中的a占用4字节,b占用4字节,c占用2字节,d占用2字节,e占用4字节
*/
汇编:
80027c4: b580 push {r7, lr}
80027c6: 480c ldr r0, [pc, #48] ; (80027f8 <.text_4>)
80027c8: 2101 movs r1, #1
80027ca: 7001 strb r1, [r0, #0]
80027cc: 2102 movs r1, #2
80027ce: 6041 str r1, [r0, #4]
80027d0: 2103 movs r1, #3
80027d2: 7201 strb r1, [r0, #8]
80027d4: 2104 movs r1, #4
80027d6: 8141 strh r1, [r0, #10]
80027d8: 2105 movs r1, #5
80027da: 60c1 str r1, [r0, #12]
80027dc: 4907 ldr r1, [pc, #28] ; (80027fc <.text_5>),浮点数存放位置
80027de: 6101 str r1, [r0, #16]
80027e0: f7fd fe8f bl 8000502 <func1_test>
80027e4: f7ff fef7 bl 80025d6 <func2_test>
80027e8: f7fe fdd0 bl 800138c <func3_test>
80027ec: f000 f838 bl 8002860 <func4_test>
80027f0: f000 f84b bl 800288a <func5_test>
80027f4: 2001 movs r0, #1
80027f6: bd02 pop {r1, pc}
080027f8 <.text_4>:
80027f8: 200010a8 .word 0x200010a8
080027fc <.text_5>:
80027fc: 3f8ccccd .word 0x3f8ccccd
/*
typedef struct
{
_u32 a;
_u8 b;
_u8 c;
_u8 d;
_u16 e;
float f;
}test_t;
static test_t tmp_struct;
tmp_struct.a = 1;
tmp_struct.b = 2;
tmp_struct.c = 3;
tmp_struct.d = 4;
tmp_struct.e = 5;
tmp_struct.f = 2.1;
通过汇编取指访问结构体成员变量得知:结构体中的a占用4字节,b占用1字节,c占用1字节,d占用2字节,e占用4字节
*/
汇编:
80027c4: b580 push {r7, lr}
80027c6: 480c ldr r0, [pc, #48] ; (80027f8 <.text_4>)
80027c8: 2101 movs r1, #1
80027ca: 6001 str r1, [r0, #0]
80027cc: 2102 movs r1, #2
80027ce: 7101 strb r1, [r0, #4]
80027d0: 2103 movs r1, #3
80027d2: 7141 strb r1, [r0, #5]
80027d4: 2104 movs r1, #4
80027d6: 7181 strb r1, [r0,