Saving Z80 stack pointer location

Thread Starter

Robin Mitchell

Joined Oct 25, 2009
819
Hi everyone,

Im in a bit of a pickle!
Just about every register in the Z80 can be saved with the exception of the stack pointer, that is, it can only be written to :/

Does anyone know of a way to save the position that the stack pointer is currently pointing to? For example, a instruction that I would have loved in the Z80 would be LD HL, SP where HL gets loaded with the value of the SP register.

Many thanks guys,
Robin
 

joeyd999

Joined Jun 6, 2011
5,283
Well, im really happy now :)

Thanks sooo much!
You're welcome.

I had to dig up some code from 1980 (I was 13 at the time) to remember how to do that. I wrote a tape base "operating system" for the TRS-80, and it included a machine language monitor/debugger. I used that sequence of instructions to capture and display the stack pointer value after a break point.
 
Top