Skip to content

Commit

Permalink
pop - pop esp is special
Browse files Browse the repository at this point in the history
 - Intel(R) Architecture Software Developer's Manual, Volume 2: Instruction Set Reference Manual
   Page 571ff: The POP ESP instruction increments the stack pointer (ESP)
   before data at the old top of stack is written into the destination.
   Incorrect behaviour was incrementing esp after data was written into it.

Thanks to Paul Banks for notice and patch.

Signed-off-by: Paul Banks <foss@paulbanks.org>
  • Loading branch information
common committed Jan 22, 2012
1 parent a81e875 commit 09bbeb5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/emu/emu_cpu_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
if( ret != 0 ) \
return ret; \
else \
cpu->reg[esp] += 4; }
if ( dst_p != &cpu->reg[esp] ) \
cpu->reg[esp] += 4; }

#define POP_WORD(cpu, dst_p) \
{ int32_t ret = emu_memory_read_word(cpu->mem, cpu->reg[esp], dst_p); \
Expand Down

0 comments on commit 09bbeb5

Please sign in to comment.