I tried to do it myself but I couldn't manage with it properly. Below is my exam question which I'd like to do properly and understand how it works. I would be grateful if you could help me with it.
Determine the destination (register or memory address) and the value stored by each instruction of the following program fragment:
mov eax, 0x8000
mov ebx, 0x40000
lea esp, [ebx]
shl eax, 16
sar ebx, 23
lea ecx, [ebx+0xff]
push ecx
sar eax, 31
push eax
mov eax, [esp+4]
sub eax, [esp]
This is the intel assembler syntax, so each line is always
eax
,esp
etc are all register names.Numbers are interpreted as number constants.
can be used to calculate an address and then load the value from that address.
I'm pretty optimistic you could have figured this out (and learned much more) by reading the obvious wikipedia page, which even links to a whole wikibook on x86 assembler.