Why does GCC move variables to a temporary location before assigning them?

Most x86 instructions (other than some specialized instructions such as movsb) can only access one memory location. Therefore a move from memory to memory requires going through a register with two mov instructions.

The mov instruction can be used in the following ways:

mov mem, reg
mov reg, mem
mov reg, reg
mov reg, imm
mov mem, imm

There is no mov mem, mem.

Note that if you had compiled with optimizations, the variables would be placed in registers so this wouldn’t be an issue.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)