C Programs include debug and release. The machine code of debug is not optimized, and the general optimization of the release version is extreme. Windows driver development, also known as check and free, has the same meaning.
Assembly structure of for: mov <cyclic variable>, <initial value> jmp BA :( modify cyclic variable )...... B: cmp <cycle variable>, <restriction variable> jge jump out of the loop (loop body )...... Jmp Afor loops are composed of jmp, cmp ...... Jle, jmp composition. Do {......} While (...) Assembly form: <loop body> cmp <loop variable>, <restriction variable> jl <cycle start point, that is, loop body> do ...... While by cmp ...... Jle. While loop assembly structure: A: cmp <loop condition> jle <skip loop> <loop body> jmp AB: loop end while by cmp ...... Jle, jmp composition. If ...... Else if ...... Else Assembly form: A: cmp <cyclic Condition A> jle <cmp in B> <if branch> B: exit loop cmp <loop Condition B> jle <else branch in C> <else if branch> C: Exit loop <else branch> at the beginning of the else if and else statements, there is an unconditional jump command to jump to the judgment end and stop the previous branch from directly entering this branch after execution. This branch can be executed only when the current judgment conditions are insufficient. switch ...... Assembly form of case [default]: mov esp, <a value>; leave space from the stack to fill with 0CCh ...... Mov eax, <judgment variable> mov dword ptr [ebp-esp], eax; move eax to the first word not needed in the top of the stack; push is the first esp-4 and then fill in the number cmp <judgment variable>, <case 1> je <case 1> cmp <judgment variable>, <case 2> je <case 2> ...... [Jmp default] <all branch statements> each case corresponds to one cmp and je. If there is no break after the case, the subsequent branches will be executed after the current case is executed. Compile a piece of code with Visual Studio and then F9 sets a breakpoint on a line -- view the disassembly code to find the above conclusion. Appendix 1 debugging code:
// Asm. cpp: defines the entry point of the console application. // # Include "stdafx. h "int _ tmain (int argc, _ TCHAR * argv []) {int myfunction (int a, int B); myfunction (10, 20); return 0 ;} int myfunction (int a, int B) {int c = 0; int I; for (I = 0; I <50; I ++) c = c + I; return c ;}
The function disassembly result is as follows:
int myfunction(int a, int b){00E81A50 55 push ebp 00E81A51 8B EC mov ebp,esp 00E81A53 81 EC D8 00 00 00 sub esp,0D8h 00E81A59 53 push ebx 00E81A5A 56 push esi 00E81A5B 57 push edi 00E81A5C 8D BD 28 FF FF FF lea edi,[ebp-0D8h] 00E81A62 B9 36 00 00 00 mov ecx,36h 00E81A67 B8 CC CC CC CC mov eax,0CCCCCCCCh 00E81A6C F3 AB rep stos dword ptr es:[edi] int c = 0;00E81A6E C7 45 F8 00 00 00 00 mov dword ptr [c],0 int i;for (i = 0; i < 50; i++)00E81A75 C7 45 EC 00 00 00 00 mov dword ptr [i],0 00E81A7C EB 09 jmp myfunction+37h (0E81A87h) 00E81A7E 8B 45 EC mov eax,dword ptr [i] 00E81A81 83 C0 01 add eax,1 00E81A84 89 45 EC mov dword ptr [i],eax 00E81A87 83 7D EC 32 cmp dword ptr [i],32h 00E81A8B 7D 0B jge myfunction+48h (0E81A98h) c = c+i;00E81A8D 8B 45 F8 mov eax,dword ptr [c] 00E81A90 03 45 EC add eax,dword ptr [i] 00E81A93 89 45 F8 mov dword ptr [c],eax 00E81A96 EB E6 jmp myfunction+2Eh (0E81A7Eh) return c;00E81A98 8B 45 F8 mov eax,dword ptr [c] }00E81A9B 5F pop edi 00E81A9C 5E pop esi 00E81A9D 5B pop ebx 00E81A9E 8B E5 mov esp,ebp 00E81AA0 5D pop ebp 00E81AA1 C3 ret