如何在汇编语言

时间:2017-10-05 02:47:58

标签: windows visual-studio assembly

我有一台Windows 10计算机和Visual Studio 2017用于我的C / C ++开发。

我目前正在阅读"Code Optimization: Effective Memory Usage",作者建议运行以下代码以捕获各种代码的准确运行时间。

XOR EAX, EAX    ;CPUID command is called to ensure all preceding commands
CPUID           ;have left the pipeline, hence, not influencing measurement results

RDTSC           ;This returns to the EAX register the lower DWord of current
                ;value of time stamp counter

MOV [clock], EAX  ; the obtained result is save to the clock variable

//...
//profiled code  ; here the profiled code is run
//--- 

XOR EAX, EAX     ; the CPUID command is executed again to ensure all preceding
CPUID            ;instructions have left the pipeline

RDTSC            ; read the new value of the time stamp counter

SUB EAX, [clock] ; calculate the difference to capture actual time to execute code fragment

我可以理解上面的汇编代码在做什么。但是我在Windows中输入的是什么,并观察结果?我应该将其保存为Visual Studio中的.asm文件,然后在其中运行吗?我应该创建一个C文件,然后在其中包含此汇编指令吗?或者,我是否应该完全远离Visual Studio并使用独立的汇编语言编译器/调试器?

0 个答案:

没有答案
相关问题