我寫了一個C++文件,我想輸出到程序集中。但是,我希望組件如下例所示進行優化:如何從visual studio 2010中的C++代碼生成優化的程序集
.386
.model flat, c
; Custom Build Step, including a listing file placed in intermediate directory
; but without Source Browser information
; debug:
; ml -c -Zi "-Fl$(IntDir)\$(InputName).lst" "-Fo$(IntDir)\$(InputName).obj" "$(InputPath)"
; release:
; ml -c "-Fl$(IntDir)\$(InputName).lst" "-Fo$(IntDir)\$(InputName).obj" "$(InputPath)"
; outputs:
; $(IntDir)\$(InputName).obj
; Custom Build Step, including a listing file placed in intermediate directory
; and Source Browser information also placed in intermediate directory
; debug:
; ml -c -Zi "-Fl$(IntDir)\$(InputName).lst" "-FR$(IntDir)\$(InputName).sbr" "-Fo$(IntDir)\$(InputName).obj" "$(InputPath)"
; release:
; ml -c "-Fl$(IntDir)\$(InputName).lst" "-FR$(IntDir)\$(InputName).sbr" "-Fo$(IntDir)\$(InputName).obj" "$(InputPath)"
; outputs:
; $(IntDir)\$(InputName).obj
; $(IntDir)\$(InputName).sbr
.code
_TEXT SEGMENT
_p$ = -8
_Array$ = 8
_size$ = 12
ClearUsingPointers PROC NEAR ; ClearUsingPointers, COMDAT
; Line 15
push ebp
mov ebp, esp
sub esp, 204 ; 000000ccH
push ebx
push esi
push edi
lea edi, DWORD PTR [ebp-204]
mov ecx, 51 ; 00000033H
mov eax, -858993460 ; ccccccccH
rep stosd
; Line 17
mov eax, DWORD PTR _Array$[ebp]
mov DWORD PTR _p$[ebp], eax
jmp SHORT $L280
$L281:
mov eax, DWORD PTR _p$[ebp]
add eax, 4
mov DWORD PTR _p$[ebp], eax
$L280:
mov eax, DWORD PTR _size$[ebp]
mov ecx, DWORD PTR _Array$[ebp]
lea edx, DWORD PTR [ecx+eax*4]
cmp DWORD PTR _p$[ebp], edx
jae SHORT $L278
; Line 18
mov eax, DWORD PTR _p$[ebp]
mov DWORD PTR [eax], 0
jmp SHORT $L281
$L278:
; Line 19
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret 0
ClearUsingPointers ENDP ; ClearUsingPointers
_TEXT ENDS
END
上述組件是如何生成的?我能夠生成的是充滿垃圾(我不知道如何解釋它),我怎樣才能縮短它,所以我可以手動優化它,編譯它並運行它?通過垃圾,我指的是多行如下。我可以刪除它們嗎? :
PUBLIC [email protected][email protected][email protected]@[email protected]@@2_NB ; std::tr1::integral_constant<bool,0>::value
PUBLIC [email protected][email protected][email protected]@[email protected]@2_NB ; std::tr1::integral_constant<bool,1>::value
PUBLIC [email protected][email protected][email protected]@[email protected]@@2IB ; std::tr1::integral_constant<unsigned int,0>::value
PUBLIC [email protected][email protected][email protected]@@2HB ; std::_Arithmetic_traits<bool>::_Rank
PUBLIC [email protected][email protected]@[email protected]@2HB ; std::_Arithmetic_traits<char>::_Rank
PUBLIC [email protected][email protected]@[email protected]@2HB ; std::_Arithmetic_traits<signed char>::_Rank
PUBLIC [email protected][email protected]@[email protected]@2HB ; std::_Arithmetic_traits<unsigned char>::_Rank
; COMDAT [email protected][email protected]@[email protected]@[email protected]@B
CONST SEGMENT
[email protected][email protected]@[email protected]@[email protected]@B DD 02H ; std::_Iosb<int>::end
CONST ENDS
; COMDAT [email protected][email protected]@[email protected]@2W4_See[email protected]@B
CONST SEGMENT
[email protected][email protected]@[email protected]@[email protected]@B DD 01H ; std::_Iosb<int>::cur
CONST ENDS
; COMDAT [email protected][email protected]@[email protected]@[email protected]@B
CONST SEGMENT
[email protected][email protected]@[email protected]@[email protected]@B DD 00H ; std::_Iosb<int>::beg
CONST ENDS
; COMDAT [email protected][email protected]@[email protected]@[email protected]@B
CONST SEGMENT
[email protected][email protected]@[email protected]@[email protected]@B DD 020H ; std::_Iosb<int>::binary
CONST ENDS
您發佈的代碼段確實在頂部有2個彙編指令,但其餘的';'行只是評論。你正在尋找的裝配在哪裏? – jcopenha
我已添加其餘。但是這些指令是什麼,他們做了什麼? – Ivan
像'.386'這樣的彙編指令並不是完全優化的代碼。現代編譯器生成'.686P'和'.XMM'。不知道這是從哪裏來的,可能有些古老。 –