Experimental Purpose
In a programming language, you can compare code writing in different programming styles, or generate assembly code from a compiler by using different compilers and compilation optimization parameters, and statically analyze the efficiency of the generated assembly code. experimental platform, tools
Under the Windows platform, use the VC6.0 tool.
Experimental design
Optimized comparison of redundant code by the same compiler at different levels of optimization.
int main ()
{
int a=0;
int b=1;
int c=2;
int d=3;
int e=4;
C=a+b;
return C;
}
The following is a compilation and code integration without optimized generation
_main PROC near; Comdat
; 4: {
Pushebp
MOVEBP, ESP
SUBESP, 84; 00000054H
Pushebx
Pushesi
Pushedi
Leaedi, DWORD PTR [ebp-84]
MOVECX, 21; 00000015H
Moveax,-858993460; Cccccccch
Rep STOSD
; 5:int a=0;
Movdword PTR _A$[EBP], 0
; 6:int b=1;
Movdword PTR _B$[EBP], 1
; 7:int c=2;
Movdword PTR _C$[EBP], 2
; 8:int d=3;
Movdword PTR _D$[EBP], 3
; 9:int e=4;
Movdword PTR _E$[EBP], 4
; 10:c=a+b;
Moveax, DWORD PTR _A$[EBP]
Addeax, DWORD PTR _B$[EBP]
Movdword PTR _C$[EBP], eax
; 11:return C;
Moveax, DWORD PTR _C$[EBP]
; 12:
; 13:}
Pop EDI
Pop esi
Pop ebx
mov esp, EBP
Pop EBP
RET 0
_main ENDP
}
The following is the release optimization level of code and compilation
_main PROC near; Comdat
; 5:int a=0;
; 6:int b=1;
; 7:int c=2;
; 8:int d=3;
; 9:int e=4;
; 10:c=a+b;
; 11:return C;
Moveax, 1
; 12:
; 13:}
RET 0
_main ENDP