How to: Inline assembler in C++ (under Visual Studio 2010)

后端 未结 6 1750
孤独总比滥情好
孤独总比滥情好 2020-12-30 15:25

I\'m writing a performance-critical, number-crunching C++ project where 70% of the time is used by the 200 line core module.

I\'d like to optimize the core using inl

6条回答
  •  梦毁少年i
    2020-12-30 16:26

    Nothing is in the registers. as the _asm block is executed. You need to move stuff into the registers. If there is a variable: 'a', then you would need to

    __asm {
      mov eax, [a]
    }
    

    It is worth pointing out that VS2010 comes with Microsofts assembler. Right click on a project, go to build rules and turn on the assembler build rules and the IDE will then process .asm files.

    this is a somewhat better solution as VS2010 supports 32bit AND 64bit projects and the __asm keyword does NOT work in 64bit builds. You MUST use external assembler for 64bit code :/

提交回复
热议问题