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

亚马逊云科技 Build On 2022 - AIot 第二季物联网专场实验心得

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

Fabric v1.1 环境搭建

arm-2-基础阶段

IDEA中创建web项目实现步骤

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

How to get started with MOOSE platform - an example of how to run the official tutorial

MNIST Handwritten Digit Recognition - Building a Perceptron from Zero for Two-Classification

LeetCode_Dec_2nd_Week

LeetCode_Dec_1st_Week
随机推荐
集合--LinkedList
file permission management ugo
LeetCode_22_Apr_4th_Week
Golang environment variable settings (2)--GOMODULE & GOPROXY
淘宝分布式文件系统存储引擎(一)
LeetCode_Nov_2nd_Week
管道重定向
const int * a 与 int * const a 的定义与区别
Code to celebrate the Dragon Boat Festival - Zongzi, your heart
Pytest common plug-in
网络通信与Socket编程概述
CAS无锁队列的实现
[Copy Siege Lion Log] Flying Pulp Academy Intensive Learning 7-Day Punch Camp-Study Notes
Thunderbolt turns off automatic updates
LeetCode_Dec_2nd_Week
[Development Miscellaneous][Editor][Code Reading]ctags & vim
(位操作符)按位与、按位或、按位异或
jdbc:mysql://localhost:3306/student?serverTimezone=CTT&useUnicode=true&characterEncoding=utf-8时报错
LeetCode_Nov_5th_Week
MNIST Handwritten Digit Recognition - Building a Perceptron from Zero for Two-Classification