A ++ and ++ A problem

xiaoxiao2021-03-06  53

Let C-language and "A , A" in C will never have problems

Here mainly studies the C language and C A , A branch and multi-operated number of dual exercises: Definition a in the language is first used, A is first After another. In fact, the double-acting doing is the end of the problem before the end of a statement. That is, if K = ( a) (A ); A is after the end of the statement, A is the end of the reply statement after the addition.

I will give a few examples (instructions with disassembly) 1 INT K = 2; int val = 0; VAL = (k ) (k );

Anti-assembly 8: INT K = 2; 00401028 MOV DWORD PTR [EBP-4], 2k address is DWORD PTR [EBP-4] 9: int val = 0; 0040102F MOV DWORD PTR [EBP-8], 0 / / VAL's address is DWORD PTR [EBP-8] 10: Val = (k ) (k ); 00401036 MOV EAX, DWORD PTR [EBP-4] // Put 2 in eax 00401039 Add Eax, DWORD PTR [ EBP-4] // Put 2 2 = 4 in EAX 0040103C MOV DWORD PTR [EBP-8], EAX // Transfer 4 in Eax Back to VAL 0040101F MOV ECX, DWORD PTR [EBP-4] 00401042 Add ECX, 1 // 00401045 MOV DWORD PTR [EBP-4], the value in the ECX // K address plus 1, k = 3

00401048 MOV EDX, DWORD PTR [EBP-4] 0040104B Add EDX, 1 // Register value 1, k = 40040104e MOV DWORD PTR [EBP-4], EDX // Move back to K

Conclusion: VAL = * (DWORD PTR [EBP-8]) = 4; K = 4

2. INT k = 2; int val = 0; k = (k ) (k );

Anti-assembly: 8: INT K = 2; 00401028 MOV DWORD PTR [EBP-4], 2 // Top 9: INT VAL = 0; 0040102F MOV DWORD PTR [EBP-8], 010: K = (K ) ( K ); 00401036 MOV EAX, DWORD PTR [EBP-4] 00401039 Add Eax, DWORD PTR [EBP-4] // 同 0040103C MOV DWORD PTR [EBP-4], EAX //, different, calculation results deposit K address K = 40040103F MOV ECX, DWORD PTR [EBP-4] 00401042 ADD ECX, 1 // Register value plus 1,00401045 MOV DWORD PTR [EBP-4], ECX // k = 500401048 MOV EDX, DWORD PTR [EBP-4] 0040104B ADD EDX, 1 // Register value plus 10040104E MOV DWORD PTR [EBP-4], EDX / / K = 6

Conclusion: k = * (DWORD PTR [EBP-4]) = 6;

3 int K = 2; int val = 0; VAL = ( K) ( K);

Disassembly: 8: INT K = 2; 00401028 MOV DWORD PTR [EBP-4], 2 // K address is DWORD PTR [EBP-4] 9: int val = 0; 0040102F MOV DWORD PTR [EBP-8] 0 // VAL's address is DWORD PTR [EBP-8] 10: Val = ( K) ( K); // K First 00 00401036 MOV EAX, DWORD PTR [EBP-4] 00401039 Add Eax The value of 1 // register plus 10040103c MOV DWORD PTR [EBP-4], EAX / / K = 30040103F MOV ECX, DWORD PTR [EBP-4] 00401042 Add ECX, 1 // The value in the k address plus 1 1 , k = 400401045 MOV DWORD PTR [EBP-4], ECX00401048 MOV EDX, DWORD PTR [EBP-4] 0040104B Add Edx, DWORD PTR [EBP-4] // K K = 80040104E MOV DWORD PTR [EBP-8] , EDX // Value in the VAL address VAL = 8

Conclusion: Val = * (DWORD PTR [EBP-8]) = 8; K = 44. INT K = 2; Int Val = 0; K = ( K) ( K); Discharge: 8: INT K = 2; 00401028 MOV DWORD PTR [EBP-4], 29: INT VAL = 0; 0040102F MOV DWORD PTR [EBP-8], 010: K = ( K) ( K); 00401036 MOV EAX, DWORD PTR [EBP-4] 00401039 Add Eax, 10040103C MOV DWORD PTR [EBP-4], EAX0040103F MOV ECX, DWORD PTR [EBP-4] 00401042 Add ECX, 100401045 MOV DWORD PTR [EBP-4], ECX00401048 MOV EDX, DWORD PTR [EBP-4] 0040104B Add EDX, DWORD PTR [EBP-4] /// The same 30040104E MOV DWORD PTR [EBP-4], EDX // Valued into the K address K = 8 Conclusion: k = * (DWORD PTR [EBP-4]) = 8;

5. INT K = 2; int val = 0; VAL = ( K) (k );

Disassembly:

8: INT K = 2; 00401028 MOV DWORD PTR [EBP-4], 29: INT VAL = 0; 0040102F MOV DWORD PTR [EBP-8], 010: VAL = ( K) (K ); 00401036 MOV EAX, DWORD PTR [EBP-4] 00401039 Add Eax, 10040103C MOV DWORD PTR [EBP-4], EAX / / K = K 1 = 30040103f MOV ECX, DWORD PTR [EBP-4] 00401042 Add ECX, DWORD PTR [ EBP-4] // K K = 600401045 MOV DWORD PTR [EBP-8], ECX // VAL = 600401048 MOV EDX, DWORD PTR [EBP-4] 0040104B Add EDX, 1 // k = K 1 = 40040104E MOV DWORD PTR [EBP-4], EDX

Conclusion: VAL = * (DWORD PTR [EBP-8]) = 6; k = 46. INT K = 2; int val = 0; K = ( K) (k );

Disassembly:

8: int K = 2; 00401028 MOV DWORD PTR [EBP-4], 29: INT VAL = 0; 0040102F MOV DWORD PTR [EBP-8], 010: K = ( K) (k ); 00401036 MOV EAX, DWORD PTR [EBP-4] 00401039 Add Eax, 1 // K 10040103C MOV DWORD PTR [EBP-4], EAX / / K = 30040103F MOV ECX, DWORD PTR [EBP-4] 00401042 Add ECX, DWORD PTR [EBP-4] // K K = 600401045 MOV DWORD PTR [EBP-4], ECX / / K = 600401048 MOV EDX, DWORD PTR [EBP-4] 0040104B Add EDX, 10040104E MOV DWORD PTR [EBP-4] EDX / / K = K 1 = 7

Conclusion: k = * (DWORD PTR [EBP-4]) = 7; K = 7

Multi-operative

Multi-operate (> 2) The number of two fucks is the same as the above (intermediate value), such as ( i) plus 1 is (i ) does not add 1. Assignment gives a variable If it is not itself, if it is itself, the number (i ) number is asged, such as N plus N, is a few examples 1. INT K = 2; int val = 0; val = (k ) (k ) ( K);

Disassembly:

331: INT K = 2; 00407488 MOV DWORD PTR [EBP-14H], 2332: INT VAL = 0; 0040748F MOV DWORD PTR [EBP-18H], 0333: VAL = (K ) (K ) ( K 00407496 MOV EAX, DWORD PTR [EBP-14H] 00407499 Add Eax, DWORD PTR [EBP-14H] // The above-mentioned double farten Monitor is eax = 4, k = 20040749c MOV ECX, DWORD PTR [ EBP-14H] 0040749F ADD ECX, 1004074A2 MOV DWORD PTR [EBP-14H], ECX // K = 3004074A5 Add Eax, DWORD PTR [EBP-14H] // EAX K = 004074A8 MOV DWORD PTR [EBP-18H], Eax // assignment to val = EAX K = 7004074AB MOV EDX, DWORD PTR [EBP-14H] 004074AE Add EDX, 1004074B1 MOV DWORD PTR [EBP-14H], EDX004074B4 MOV EAX, DWORD PTR [EBP-14H] 004074B7 Add EAX , 1004074BA MOV DWORD PTR [EBP-14H], EAX

Conclusion: Val = * (DWORD PTR [EBP-18H]) = 6; K = 5

2. INT K = 2; int val = 0; k = (k ) (k ) ( k); antihui assembly: 331: int K = 2; 00407488 MOV DWORD PTR [EBP-14H], 2332: Int Val = 0; 0040748F MOV DWORD PTR [EBP-18H], 0333: K = (k ) (k ) ( K); 00407496 MOV Eax, DWORD PTR [EBP-14H] 00407499 Add Eax, DWORD PTR [EBP -14H] 0040749C MOV ECX, DWORD PTR [EBP-14H] 0040749F Add ECX, 1004074A2 MOV DWORD PTR [EBP-14H], ECX004074A5 Add Eax, DWORD PTR [EBP-14H] 004074A8 MOV DWORD PTR [EBP-14H], EAX // Assignment to K = EAX K = 7004074AB MOV EDX, DWORD PTR [EBP-14H] 004074AE Add EDX, 1004074B1 MOV DWORD PTR [EBP-14H], EDX // K = K 1 = 8004074B4 MOV EAX, DWORD PTR [EBP-14H] 004074B7 Add Eax, 1004074BA MOV DWORD PTR [EBP-14H], EAX / / K = K 1 = 9

Conclusion: Val = * (DWORD PTR [EBP-14H]) = 9;

Lifting a question 1.int k = 2; int val = 0; VAL = ( K) ( K) ( ) ( K) ( K) ( K) (k ) (k ) (k ); VAL = 4 4 4 5 6 7 8 8 8 8 = 62

2.int k = 2; int val = 0; k = ( K) ( K) (K ) ( K) ( K) ( K) (k ) (k ) (k ); 4 K k = 4 4 4 5 6 7 8 8 8 8 in plus 4 = 66

"A -, - A" is the same as A, A .

转载请注明原文地址:https://www.9cbs.com/read-114979.html

New Post(0)