niXman:
X>хз, о чем вы...
X>мой компилятор всегда генерит mov eax, 5; ret;
Вот скомпилёное 2017-й студией, релиз:
; Listing generated by Microsoft (R) Optimizing Compiler Version 19.11.25325.0
TITLE c:\projects\vc2017\log2\log2.cpp
.686P
.XMM
include listing.inc
.model flat
INCLUDELIB OLDNAMES
EXTRN @__security_check_cookie@4:PROC
PUBLIC ??$my_log2@I@@YAHI@Z ; my_log2<unsigned int>
PUBLIC _main
; Function compile flags: /Ogtp
; COMDAT _main
_TEXT SEGMENT
_main PROC ; COMDAT
; File c:\projects\vc2017\log2\log2.cpp
; Line 6
mov ecx, 21 ; 00000015H
call ??$my_log2@I@@YAHI@Z ; my_log2<unsigned int>
inc eax
; Line 44
ret 0
_main ENDP
_TEXT ENDS
; Function compile flags: /Ogtp
; COMDAT ??$my_log2@I@@YAHI@Z
_TEXT SEGMENT
??$my_log2@I@@YAHI@Z PROC ; my_log2<unsigned int>, COMDAT
; _n$ = ecx
; File c:\projects\vc2017\log2\log2.cpp
; Line 6
test ecx, ecx
je SHORT $LN3@my_log2
shr ecx, 1
call ??$my_log2@I@@YAHI@Z ; my_log2<unsigned int>
inc eax
; Line 7
ret 0
$LN3@my_log2:
; Line 6
or eax, -1
; Line 7
ret 0
??$my_log2@I@@YAHI@Z ENDP ; my_log2<unsigned int>
_TEXT ENDS
END