当前位置:网站首页>counting cycle
counting cycle
2022-08-04 06:34:00 【xcy6666】
.section .data
cycle_str:
.asciz "cycle count is: %lu\n"
long:
.quad 5
.section .text
.globl _start
_start:
# measure base = mov + rdtsc
xorq %rax, %rax
rdtsc # write time stamp to rax
movq %rax, %rcx # %rcx = %rax
rdtsc # write time stamp to rax
subq %rcx, %rax # %rax = %rax -%rcx
movq %rax, %rsi
movq $cycle_str, %rdi
movq $0, %rax
call printf
# measure base + xchgq
xorq %rax, %rax
rdtsc # write time stamp to rax
movq %rax, %rcx # %rcx = %rax
xchgq long, %rdx
rdtsc # write time stamp to rax
subq %rcx, %rax # %rax = %rax -%rcx
# print %rax
movq %rax, %rsi
movq $cycle_str, %rdi
movq $0, %rax
call printf
# exit
movq $1,%rax # syscall id: sys_exit
movq $0,%rbx # exit code 0
int $0x80
all:
as -o hello.o hello.S
ld -o hello hello.o -lc --dynamic-linker /lib64/ld-linux-x86-64.so.2
./hello
clean:
rm *.o hello
https://docs.microsoft.com/en-us/cpp/intrinsics/rdtsc?view=msvc-160
https://cs.brown.edu/courses/cs033/docs/guides/x64_cheatsheet.pdf
https://www.intel.com/content/dam/www/public/us/en/documents/white-papers/ia-32-ia-64-benchmark-code-execution-paper.pdf
边栏推荐
- file editor
- 动态内存管理-C语言
- [开发杂项][编辑器][代码阅读]ctags&vim
- LeetCode_Dec_3rd_Week
- LeetCode_22_Apr_4th_Week
- Deep Learning Theory - Overfitting, Underfitting, Regularization, Optimizers
- 亚马逊云科技 Build On 2022 - AIot 第二季物联网专场实验心得
- 在AWS-EC2中安装Minikube集群
- The Unity of ML - agents interpret parameter Settings
- file permission management ugo
猜你喜欢
随机推荐
LeetCode_Nov_4th_Week
多线程顺序输出
深度学习理论——过拟合、欠拟合、正则化、优化器
Windows10重置MySQL用户密码
The second official example analysis of the MOOSE platform - about creating a Kernel and solving the convection-diffusion equation
C语言无符号整型运算
常见的一些排序
MySQL基础
Deep learning, "grain and grass" first--On the way to obtain data sets
树和二叉树
使用JS在浏览器中打印菱形
FAREWARE ADDRESS
集合--LinkedList
在AWS-EC2中安装Minikube集群
Cut the hit pro subtitles export of essays
实现高并发服务器(二)
安装MySQL的详细步骤
[Daily Office][Miscellaneous][vscode]tab space
【c语言】整数的二进制表现形式是什么?
Install Minikube Cluster in AWS-EC2