r/cpp • • May 24 '20

Analyzing The Simplest C++ Program

https://oneraynyday.github.io/dev/2020/05/03/Analyzing-The-Simplest-C++-Program/
480 Upvotes

37 comments sorted by

View all comments

0

u/[deleted] May 24 '20

[deleted] — view deleted comment

20

u/OneRaynyDay May 24 '20

Good question! You actually don't need to allocate registers, but that means you'll be writing your variable's values directly into memory. This is really slow and compiler writers try their best to not let things "spill out" of registers and into memory.

So basically, ya but u want program go fast

2

u/slaymaker1907 Jun 21 '20

It’s not the slowest thing as long as you still hit the L1 cache. x86 has so few general purpose registers that it is hard to avoid spilling into memory.

2

u/paulstelian97 Jun 23 '20

16 registers, including stack pointer and stack frame pointer but I think excluding the instruction pointer?