<<< Understanding memory is important | Index | Memory access by the CPU >>> |
y = y + x;
A disassembly of a debug build on Windows 32-bit platform shows
mov eax, dword ptr [y] ; load y from memory into CPU register EAX add eax, dword ptr [x] ; compute EAX + x, save result in EAX mov dword ptr [y], eax ; save result from EAX in memory that belongs to y
Only one instruction (add) deals with the math.
The other two instructions (mov) transfer values to/from memory.
Can CPU add two memory values in one step?
<<< Understanding memory is important | Index | Memory access by the CPU >>> |