Hacker News new | ask | show | jobs
by souprock 2030 days ago
It sometimes seems to count, but then an interrupt happens or there is a backwards jump. That isn't counting. 42, 45, 47, 3, 4, 7, 37953, 37955, 37959, 11, 12, 15...

Actual counting on real hardware does happen. For example, x86 has the CX/ECX/RCX register for string operations. That has a far better justification for being called a program counter, but still that would be awful terminology. Another example is the CTR register of PowerPC, commonly used with an instruction that decrements it and then conditionally branches to do a loop. Even a cycle counter has better justification for being called a program counter.

1 comments

Yes, I let go of "counters" some two decades ago. Personally prefer index or just i, instead.

The way it used to go. Call something counter. Increment it each loop. Use goto for looping. Over time, add more gotos and change "counter" value. It tends to creep in, and clear names are important.