Z80 stack pointer

Thread Starter

Dr.Wily

Joined Mar 27, 2010
1
I am having problems using the stack pointer on the Z80. Here is basically what I am trying to do.

LD SP, 27FFh
LD HL, ABCD
PUSH HL
HLT

I look at address 27FFh and neither CDh or ABh is there. I also look at address 27FEh and it is not there. The memory logic is working because I can do this:

LD HL, 27FFh
LD (HL), AB
HLT

The value will be there. Any suggestions?
 
On the Z80 PUSH instruction the stack pointer is decremented 2 places first. Then the value is stored where the pointer points. On a POP the value is read from memory and the stack pointer is then incremented 2 places. Your values are at 27FD and 27FE.
 
Top