I'm creating a program that shows the registers called dumpRegisters. The registers need to match what is shown in the Registers window in the debugger (using Visual Studio). The registers in the window of the debugger are: EAX, EBX, ECX, EDX, ESI, EDI, EBP, ESP, EIP, EFL. 10 registers total.
I know the Irvine Library already has this procedure, but I'm creating it from scratch.
I'm able to show most of the registers. However, I'm struggling on how to display the ESP (extended stack pointer) register?
I use push and pop throughout the program, so when I call a showRegister procedure, it outputs the ESP at that point, but ESP continues to change, so the when the program exits, the ESP I showed is not the same. I've tried to push and pop esp, however, it still doesn't match depending on where I push and pop esp, sometimes it also only shows the first 4 registers.
How can I get the ESP register to match the registers window in the debugger?
dumpRegisters PROC
push eax
push edx
mov edx, OFFSET essp
mov eax, esp
INVOKE showRegister, OFFSET essp, esp
pop edx
pop eax
dumpRegisters ENDP
showRegister PROC,
regName:PTR BYTE , regValue:DWORD
;push esp
call writeString
call writeHex
Tab
;pop esp
ret
showRegister ENDP