News for hackers. Stuff that matters.
Re:Why do arrays start at 0? by blueflow on Wednesday August 24, 2022 @04:33PM (#32585359)
Machine code is special because its the only thing the CPU can actually execute.
Re:Why do arrays start at 0? by clhodapp on Wednesday August 24, 2022 @09:33PM (#32588280)
... then the c.p.u. further compiles this to it's internal code as it executes it. “machine code” really is no more special in this chain of events than, say, LLVM IR.

I think this is the core point. Even though you are mechanically feeding machine code into the CPU, modern CPUs deeply transform your program before (or even while) running it, with potentially deep performance implications. With modern CPUs, the only choice we truly have is which compiler we trust to optimize our program.

Re:Why do arrays start at 0? by iopq on Thursday August 25, 2022 @02:20AM (#32590238)
Sometimes it executes it exactly how you think it will execute. But it's still slower because the "less optimized code" fit in its cache.
Re:Why do arrays start at 0? by izacus on Thursday August 25, 2022 @06:17AM (#32591763)
It's slightly different - machine code is special because it's a visible API between our programming work and the CPU sillicon. Microcode is private implementation detail which you usually can't affect as a software developer. Machine code is something you are directly creating by writing things though.
Re:Why do arrays start at 0? by Blikkentrekker on Sunday August 28, 2022 @12:40PM (#32629740)
Why is that visible a.p.i. different than, say, LLVM i.r. which is also a visible a.p.i.?

Why is the c.p.u. special?

Re:Why do arrays start at 0? by pjmlp on Thursday August 25, 2022 @04:59AM (#32591294)
Except if the CPU is microcoded, those instructions might not mean what you think they do, and you need something like Intel's V-Tune to actually understand what the CPU is doing with them.
Re:Why do arrays start at 0? by blueflow on Thursday August 25, 2022 @05:04AM (#32591315)
> ... to actually understand what the CPU is doing with them.

x86 has a developers manual for this purpose.

Re:Why do arrays start at 0? by pjmlp on Thursday August 25, 2022 @05:33AM (#32591500)
It has, and if you manage to know everything on those pages, for every single processor on the market, while taking into consideration motherboard architectures, and OS workloads you're our hero.

We are way beyond MS-DOS days and Michael Abrash's books.