??????????????????
???????????? ???????[ 2017/2/10 10:17:36 ] ??????????? ???? ????
????????????????????????????????????????????????????????
????????????????3???
????1 #include <stdio.h>
????2 main()
????3 {
????4 int x[3][4] = {1??3??5??7??9??11??2??4??6??8??10??12} ;
????5 int (*p)[4] = x?? k = 1?? m?? n = 0;
????6 for(m=0; m < 2; m++)
????7 n += *(*(p+m)+k);
????8 printf("%d
"??n);
????9 }
??????д?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????C??????????????????????????????????????????????????????λ????????????岻???????????????????????????????Array of pointers???????????array??????????????array???????pointers??array??????????????pointer of an array???????pointer????????pointer ????????????????array????????????array?????????????????????????????????????????????????
????????????????????x???????????????飬p???????????????????????4?????飬???????x?????У?x??????????????4??int?????飩?????????for????????ζ?p+1????????k???????1????????????????????????n??????????????2?Σ???????1?к??2?У?????????????0??1???????????????x[0][1]??x[1][1]?????????????????3+11=14.
??????????????????????????GCC??????????????????????μ????
????1 0x401340 push %ebp
????2 0x401341 mov %esp??%ebp
????3 0x401343 and $0xfffffff0??%esp
????4 0x401346 sub $0x50??%esp
????5 0x401349 call 0x4019d0 <__main>
????6 0x40134e movl $0x1??0x10(%esp)
????7 0x401356 movl $0x3??0x14(%esp)
????8 0x40135e movl $0x5??0x18(%esp)
????9 0x401366 movl $0x7??0x1c(%esp)
????10 0x40136e movl $0x9??0x20(%esp)
????11 0x401376 movl $0xb??0x24(%esp)
????12 0x40137e movl $0x2??0x28(%esp)
????13 0x401386 movl $0x4??0x2c(%esp)
????14 0x40138e movl $0x6??0x30(%esp)
????15 0x401396 movl $0x8??0x34(%esp)
????16 0x40139e movl $0xa??0x38(%esp)
????17 0x4013a6 movl $0xc??0x3c(%esp)
????18 0x4013ae lea 0x10(%esp)??%eax
????19 0x4013b2 mov %eax??0x44(%esp)
????20 0x4013b6 movl $0x1??0x40(%esp)
????21 0x4013be movl $0x0??0x48(%esp)
????22 0x4013c6 movl $0x0??0x4c(%esp)
????23 0x4013ce jmp 0x4013f9 <main+185>
????24 0x4013d0 mov 0x4c(%esp)??%eax
????25 0x4013d4 lea 0x0(??%eax??4)??%edx
????26 0x4013db mov 0x40(%esp)??%eax
????27 0x4013df add %edx??%eax
????28 0x4013e1 lea 0x0(??%eax??4)??%edx
????29 0x4013e8 mov 0x44(%esp)??%eax
????30 0x4013ec add %edx??%eax
????31 0x4013ee mov (%eax)??%eax
????32 0x4013f0 add %eax??0x48(%esp)
????33 0x4013f4 addl $0x1??0x4c(%esp)
????34 0x4013f9 cmpl $0x1??0x4c(%esp)
????35 0x4013fe jle 0x4013d0 <main+144>
????36 0x401400 mov 0x48(%esp)??%eax
????37 0x401404 mov %eax??0x4(%esp)
????38 0x401408 movl $0x403024??(%esp)
????39 0x40140f call 0x401c40 <printf>
????40 0x401414 leave
????41 0x401415 ret
???????е?4?б???????????????auto???????????????0x50????6~17?У???????????????x??????????У?x[0][0]?????%esp+10??19~22?з???p??k??m??n????????????п????????p??????????leal???????????????????p??????4???????????????????С??????????????????????????
????????????о?????????ζ??????????в????????jle???????λ??????24~35?С???????C????????У?for?????body-statement?????臨????????????????????????32?е?add???33?е?addl?????????????????34???????cmpl????ж??С????32?е?add????У?%esp+48???????n??31????%eax???????????????????????%eax??????%eax?У???????C????????????????*???30?е?add?????%eax???????????????*(p+m)+k?????
?????????????????????ν?????????????24???%esp+0x4c??m???????25????leal???m*4??????%edx??????У?26???%esp+0x40??k?????????????%eax?У?27?н?%eax??%edx?????????????????????4m+k??28?н??????????????4?????????????????29??????????????????????????????????*(p+m)+k??????????25??leal??????????4???????????????????????4???????????н?(*p)[4]???(*p)[3]?????????????????′????????????????
????1 0x4013d0 mov 0x4c(%esp)??%edx
????2 0x4013d4 mov %edx??%eax
????3 0x4013d6 add %eax??%eax
????4 0x4013d8 add %eax??%edx
????5 0x4013da mov 0x40(%esp)??%eax
????6 0x4013de add %edx??%eax
????7 0x4013e0 lea 0x0(??%eax??4)??%edx
????8 0x4013e7 mov 0x44(%esp)??%eax
????9 0x4013eb add %edx??%eax
????10 0x4013ed mov (%eax)??%eax
????11 0x4013ef add %eax??0x48(%esp)
????12 0x4013f3 addl $0x1??0x4c(%esp)
????13 0x4013f8 cmpl $0x1??0x4c(%esp)
????14 0x4013fd jle 0x4013d0 <main+144>
????????????????????add?????????鳤??3??????????leal??????????鳤??4????????????????????????????С??????????????λ?????????泣????????????????????C???????????????????????????????????????
????????????????????????????????飬?????????????????????????????????????????顣??????????????????????????“??????”??????????????????????????洢??????????????????????????У?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????г??????????????£?????????÷????????????????????????????????????????????????????г?????????
????????????????????D???????ElementType D[R][C]???е?i??j?е???????????????????
????&D[i][j]=xD+L(C·i+j)??????xD???????????????L???????????????????С??C???????г????
????????????????????????μ???????????????????xD=p??i=m??j=k??
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11