Andes Workshop http://forum.andestech.com/ |
|
c struct - the variable using memory http://forum.andestech.com/viewtopic.php?f=25&t=906 |
Page 1 of 1 |
Author: | jerry [ Tue Dec 16, 2014 5:06 pm ] |
Post subject: | c struct - the variable using memory |
1. struct Test1{ unsigned int ui1; unsigned int ui2; char c1; char c2; }; The memory map Attachment: test1.jpg [ 16.5 KiB | Viewed 15901 times ] The assemble code Code: t1.ui1=1; c8e: b0 07 addri36.sp $r0,#0x1c c90: 84 21 movi55 $r1,#0x1 c92: b6 20 swi450 $r1,[$r0] t1.ui2=2; c94: b0 07 addri36.sp $r0,#0x1c c96: 84 22 movi55 $r1,#0x2 c98: a8 41 swi333 $r1,[$r0+#0x4] t1.c1=3; c9a: b0 07 addri36.sp $r0,#0x1c c9c: 84 23 movi55 $r1,#0x3 c9e: 10 10 00 08 sbi $r1,[$r0+#0x8] t1.c2=4; ca2: b0 07 addri36.sp $r0,#0x1c ca4: 84 24 movi55 $r1,#0x4 ca6: 10 10 00 09 sbi $r1,[$r0+#0x9] 2. struct Test2{ char c1; unsigned int ui1; char c2; unsigned int ui2; }; The memory map Attachment: test2.jpg [ 28.43 KiB | Viewed 15901 times ] The assemble code Code: t2.c1=1; caa: b0 03 addri36.sp $r0,#0xc cac: 84 21 movi55 $r1,#0x1 cae: ae 40 sbi333 $r1,[$r0+#0x0] t2.ui1=2; cb0: b0 03 addri36.sp $r0,#0xc cb2: 84 22 movi55 $r1,#0x2 cb4: a8 41 swi333 $r1,[$r0+#0x4] t2.c2=3; cb6: b0 03 addri36.sp $r0,#0xc cb8: 84 23 movi55 $r1,#0x3 cba: 10 10 00 08 sbi $r1,[$r0+#0x8] t2.ui2=4; cbe: b0 03 addri36.sp $r0,#0xc cc0: 84 24 movi55 $r1,#0x4 cc2: a8 43 swi333 $r1,[$r0+#0xc] 3. struct Test3{ char c1; unsigned int ui1; char c2; unsigned int ui2; }__attribute__((packed)); The memory map Attachment: test3.jpg [ 16.76 KiB | Viewed 15901 times ] The assemble Code: t3.c1=1;
cc4: b0 02 addri36.sp $r0,#0x8 cc6: 84 21 movi55 $r1,#0x1 cc8: ae 40 sbi333 $r1,[$r0+#0x0] t3.ui1=2; cca: b0 02 addri36.sp $r0,#0x8 ccc: 8c 01 addi45 $r0,#0x1 cce: a6 40 lbi333 $r1,[$r0+#0x0] cd0: 54 10 80 00 andi $r1,$r1,#0x0 cd4: 58 10 80 02 ori $r1,$r1,#0x2 cd8: ae 40 sbi333 $r1,[$r0+#0x0] cda: a6 41 lbi333 $r1,[$r0+#0x1] cdc: 54 10 80 00 andi $r1,$r1,#0x0 ce0: ae 41 sbi333 $r1,[$r0+#0x1] ce2: a6 42 lbi333 $r1,[$r0+#0x2] ce4: 54 10 80 00 andi $r1,$r1,#0x0 ce8: ae 42 sbi333 $r1,[$r0+#0x2] cea: a6 43 lbi333 $r1,[$r0+#0x3] cec: 54 10 80 00 andi $r1,$r1,#0x0 cf0: ae 43 sbi333 $r1,[$r0+#0x3] t3.c2=3; cf2: b0 02 addri36.sp $r0,#0x8 cf4: 84 23 movi55 $r1,#0x3 cf6: ae 45 sbi333 $r1,[$r0+#0x5] t3.ui2=4; cf8: b0 02 addri36.sp $r0,#0x8 cfa: 8c 06 addi45 $r0,#0x6 cfc: a4 40 lhi333 $r1,[$r0+#0x0] cfe: 54 10 80 00 andi $r1,$r1,#0x0 d02: 58 10 80 04 ori $r1,$r1,#0x4 d06: ac 40 shi333 $r1,[$r0+#0x0] d08: a4 41 lhi333 $r1,[$r0+#0x2] d0a: 54 10 80 00 andi $r1,$r1,#0x0 d0e: ac 41 shi333 $r1,[$r0+#0x2] |
Page 1 of 1 | All times are UTC + 8 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |