(gdb) disass p
Dump of assembler code for function p:
0x080484d4 <+0>: push ebp
0x080484d5 <+1>: mov ebp,esp
0x080484d7 <+3>: sub esp,0x68
0x080484da <+6>: mov eax,ds:0x8049860 <---
0x080484df <+11>: mov DWORD PTR [esp],eax <---
...
0x0804853d <+105>: leave
0x0804853e <+106>: ret
I want to understand something about the two lines denoted with arrows in the code above.
I know the first mov instruction moves the address ds:0x8049860 into the register eax, and then in the second line we mov the content of eax (I suppose it contains an address at this point) into the 32-bits memory pointed with esp. (I hope this is correct, please correct me if I'm wrong).
What I dont understand is why we need the register eax as an intermediary between the two instructions?
Would it be possible if we replaced the two instructions with something like
mov DWORD PTR [esp], ds:0x8049860?