Back
Close

Computing with Data

elgeish
133.7K views
Previous: The Log-Scale Trick Next: Bash - Introduction

Use of Assembly Language in High-Level Languages

This example simply executes the RDTSC assembly instruction, which reads the CPU's timestamp counter, then stores the higher 32 bits into the EDX register and the lower ones into the EAX register. The value of EAX is then assigned to the timeStampCounter variable in C++ and printed out:

// { autofold
#include <iostream>
using namespace std;
// }
int main() {
uint timeStampCounter = 0;
asm("rdtsc": "=a" (timeStampCounter));
std::cout << timeStampCounter << std::endl;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants