当前位置:网站首页>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
边栏推荐
猜你喜欢

最全的最详细的指针讲解(C语言)

CSDN大礼包--高校圆桌派大礼包

Question 1000: Input two integers a and b, calculate the sum of a+b, this question is multiple sets of test data

arm learning-1-development board

通用解决端口占用问题

题目1000:输入两个整数a和b,计算a+b的和,此题是多组测试数据

在AWS-EC2中安装Minikube集群

Deep learning, "grain and grass" first--On the way to obtain data sets

淘宝分布式文件系统存储引擎(一)

MOOSE平台使用入门攻略——如何运行官方教程的例子
随机推荐
LeetCode_Nov_4th_Week
第三章 标准单元库(下)
[daily office][ssh]cheatsheet
Rules.make - suitable for viewing in edit mode
C语言数组的深度分析
【C语言】数组名是什么
IDEA中创建web项目实现步骤
LeetCode_Dec_3rd_Week
sbl_init.asm-适合在编辑模式下看
[日常办公][ssh]cheatsheet
Pytest common plug-in
[CV-Learning] Linear Classifier (SVM Basics)
[开发杂项][调试]debug into kernel
[Daily Office][Miscellaneous][vscode]tab space
[English learning][sentence] good sentence
The usefulness of bind() system call
Shell脚本执行的三种方式
MNIST Handwritten Digit Recognition - Lenet-5's First Commercial Grade Convolutional Neural Network
[Development miscellaneous][Debug]debug into kernel
Object.requireNonNull 方法说明