Click here to Skip to main content
15,888,351 members
Home / Discussions / C#
   

C#

 
GeneralRe: tables Pin
csrss25-Oct-09 8:05
csrss25-Oct-09 8:05 
GeneralRe: tables Pin
Richard MacCutchan25-Oct-09 8:33
mveRichard MacCutchan25-Oct-09 8:33 
GeneralRe: tables Pin
csrss25-Oct-09 11:14
csrss25-Oct-09 11:14 
AnswerRe: tables Pin
Luc Pattyn25-Oct-09 12:32
sitebuilderLuc Pattyn25-Oct-09 12:32 
GeneralRe: tables Pin
Richard MacCutchan25-Oct-09 12:37
mveRichard MacCutchan25-Oct-09 12:37 
GeneralRe: tables Pin
Luc Pattyn25-Oct-09 12:42
sitebuilderLuc Pattyn25-Oct-09 12:42 
GeneralRe: tables [modified] Pin
csrss25-Oct-09 14:25
csrss25-Oct-09 14:25 
QuestionNOPs in disassembly Pin
Ekoj Lirpa25-Oct-09 6:34
Ekoj Lirpa25-Oct-09 6:34 
Hello,

this is my first post here, up to now I have only been reading. My question arose from an argument about my habit to write lines like

if( SomeBooleanvariable == true)
{
    // do something
}


instead of

if( SomeBooleanvariable)
{
    // do something
}


Granted, it's a bit verbose, but I did not think it would cause the compiler to generate slightly inefficient code. Looking at the disassembly settled the arguement. It generated the same code in both cases.

When looking at the disassembly I noticed something else. The compiler had inserted some apparently needless NOP instructions. What are they good for? This was taken from the release build:

            if (bValue == true)
00000000  push        ebp  
00000001  mov         ebp,esp 
00000003  push        ebx  
00000004  sub         esp,8 
00000007  mov         dword ptr [ebp-0Ch],ecx 
0000000a  mov         dword ptr [ebp-8],edx 
0000000d  cmp         dword ptr ds:[01BC150Ch],0 
00000014  je          0000001B 
00000016  call        685A9061 
0000001b  movzx       eax,byte ptr [ebp-8] 
0000001f  test        eax,eax 
00000021  je          0000003E 
            {
                m_lFlags = m_lFlags | (long)Flags;
00000023  mov         eax,dword ptr [ebp-0Ch] 
00000026  mov         edx,dword ptr [eax+8] 
00000029  mov         eax,dword ptr [eax+4] 
0000002c  or          eax,dword ptr [ebp+8] 
0000002f  or          edx,dword ptr [ebp+0Ch] 
00000032  mov         ecx,dword ptr [ebp-0Ch] 
00000035  mov         dword ptr [ecx+4],eax 
00000038  mov         dword ptr [ecx+8],edx 
0000003b  nop              
0000003c  jmp         0000005D 
            }
            else
            {
                m_lFlags = m_lFlags & ~(long)Flags;
0000003e  mov         eax,dword ptr [ebp+8] 
00000041  mov         edx,dword ptr [ebp+0Ch] 
00000044  not         eax  
00000046  not         edx  
00000048  mov         ebx,dword ptr [ebp-0Ch] 
0000004b  and         eax,dword ptr [ebx+4] 
0000004e  and         edx,dword ptr [ebx+8] 
00000051  mov         ecx,dword ptr [ebp-0Ch] 
00000054  mov         dword ptr [ecx+4],eax 
00000057  mov         dword ptr [ecx+8],edx 
            }


It has been a while since I really did some assembly on an x86 CPU and I see no immediate use for the NOP at address 0000003b. In the debug build there were more of them, but this one did not disappear in the release build.
GeneralRe: NOPs in disassembly Pin
Henry Minute25-Oct-09 7:26
Henry Minute25-Oct-09 7:26 
GeneralRe: NOPs in disassembly Pin
Ekoj Lirpa25-Oct-09 7:51
Ekoj Lirpa25-Oct-09 7:51 
GeneralRe: NOPs in disassembly Pin
Richard MacCutchan25-Oct-09 8:03
mveRichard MacCutchan25-Oct-09 8:03 
GeneralRe: NOPs in disassembly Pin
GameZelda25-Oct-09 8:29
GameZelda25-Oct-09 8:29 
GeneralRe: NOPs in disassembly Pin
Ekoj Lirpa25-Oct-09 8:48
Ekoj Lirpa25-Oct-09 8:48 
GeneralRe: NOPs in disassembly [modified] Pin
harold aptroot25-Oct-09 9:06
harold aptroot25-Oct-09 9:06 
AnswerRe: NOPs in disassembly Pin
PIEBALDconsult25-Oct-09 15:26
mvePIEBALDconsult25-Oct-09 15:26 
QuestionCustom Control Pin
Kumold25-Oct-09 3:50
Kumold25-Oct-09 3:50 
AnswerRe: Custom Control Pin
Ekoj Lirpa25-Oct-09 8:30
Ekoj Lirpa25-Oct-09 8:30 
QuestionSecurity when working wtih .mdf Pin
cdpace25-Oct-09 3:29
cdpace25-Oct-09 3:29 
QuestionCrystal Repor Problem Pin
Thaer Hamael25-Oct-09 2:09
Thaer Hamael25-Oct-09 2:09 
Questiongetting Zedgraph into a stand-alone application Pin
Member 466007224-Oct-09 23:39
Member 466007224-Oct-09 23:39 
AnswerRe: getting Zedgraph into a stand-alone application Pin
Christian Graus24-Oct-09 23:42
protectorChristian Graus24-Oct-09 23:42 
AnswerRe: getting Zedgraph into a stand-alone application Pin
Nagy Vilmos25-Oct-09 22:59
professionalNagy Vilmos25-Oct-09 22:59 
GeneralRe: getting Zedgraph into a stand-alone application Pin
JoeHapp2-Jun-11 7:39
JoeHapp2-Jun-11 7:39 
Questionsocket minimum recieve Pin
programmer.coder24-Oct-09 22:13
programmer.coder24-Oct-09 22:13 
QuestionProblem with extracting file names from the file names returned by FTP LIST command Pin
nccsbim07124-Oct-09 21:04
nccsbim07124-Oct-09 21:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.