r/programming • • May 01 '18

C Is Not a Low-level Language - ACM Queue

https://queue.acm.org/detail.cfm?id=3212479
152 Upvotes

303 comments sorted by

View all comments

Show parent comments

6

u/MINIMAN10001 May 01 '18

If we want to get this stupidly nitpicky x86 assembly isn't low level because x86 is a virtual machine

3

u/[deleted] May 02 '18

If we want to get this stupidly nitpicky x86 assembly isn't low level because x86 is a virtual machine

The Intel 80x86 CPU's are not virtual machines. They do have a 8086 virtual mode, but that is not a virtual machine. Assembly language is still low level since direct opcodes are being assembled.

3

u/MINIMAN10001 May 02 '18

The article isn't about virtual mode. It's about the fact that the opcodes you give the processor no longer execute the instructions that they used to execute because it is now a virtual machine.

CMP and JMPcc and now executed on the CPU as a single instruction on the processor.

xor eax, eax doesn't clear eax just marks it as unused freeing it up to the pool of 168 registers.

mov eax, ebx doesn't move eax to ebx it renames ebx register to eax

I'll quote this one

But because the processor is massively out-of-order, I can continue executing instructions in the future that don't depend upon this memory read. This includes other memory reads. Inside the CPU, the results always appear as if the processor executed everything in-order, but outside the CPU, things happen in strange order.

This means any attempt to get smooth, predictable execution out of the processor is very difficult. That means "side-channel" attacks on x86 leaking software crypto secrets may always be with us.

The upshot is this: Intel's x86 is a high-level language. Coding everything up according to Agner Fog's instruction timings still won't produce the predictable, constant-time code you are looking for.