Reviving SP question


[Prev][Next][Index][Thread]

Reviving SP question



I previously wrote to this list about the SP register.  I have one little
question left.  Since SP is a 16 bit register and the stack is built from
$FFFF, then a push and a pop looks something like this (I could be wrong,
so correct me if I am):

Push:
  SP=PC
  DEC SP
  DEC SP

Pop:
  INC SP
  INC SP
  PC=SP

I have a couple questions about the above "code":
Do I need 1 or 2 INCs/DECs?
Should the DEC(s) in the Push code come before and the INC(s) in the Pop
come after or are both in the correct position?

If you are NOT sure about some of this, don't respond.  Messing with the SP
register is for experienced programmers only.  So, if you understand this
area of Z80 ASM, then reply.  Thanks in advance.


                 Thomas J. Hruska -- thruska@tir.com
Shining Light Productions -- "Meeting the needs of fellow programmers"
         http://www.geocities.com/SiliconValley/Heights/8504
                    http://shinelight.home.ml.org


Follow-Ups: