; Program to print the time-stamp counter on x64 Linux ; Author: illustrissimus ; To build and run: ; nasm -f elf64 -o rdtsc.o rdtsc.asm ; ld -o rdtsc rdtsc.o; strip -s rdtsc ; ./rdtsc |od -An -t x4 |tr -d ' ' ; To inspect: ; objdump -M intel -d rdtsc ; To check if the instruction is supported: ; grep tsc /proc/cpuinfo default rel global _start section .bss tscv_low: resb 4 tscv_high: resb 4 section .text _start: ; read the counter rdtsc mov dword [tscv_low], eax mov dword [tscv_high], edx ; write to stdout mov rax, 1 ; write mov rdi, 1 ; stdout lea rsi, [tscv_high] mov rdx, 4 ; number of octets to print syscall mov rax, 1 ; write mov rdi, 1 ; stdout lea rsi, [tscv_low] mov rdx, 4 ; number of octets to print syscall ; exit the program mov rax, 60 ; exit mov rdi, 0 ; exit code syscall