why does this

movw (%eax), 4(%esp)

generate an error messgae after invoking the assembler. using GAS.

In the x86 processors it is not possible to do an operation between two adresses of memory. Simply it is impossible to copy directly from memory to memory. You need to copy to a register and copy the content of the register to the target address.