Jump to content

Conversion of Z80 code to TMS9900

Recommended Posts

Just now, Lee Stewart said:


should be

			MOV *SP+,Rn



Thank you!  :)


Share this post

Link to post
Share on other sites

Yes, these two/one instruction(s) are what I typically use for PUSH and POP. I prefer letting the stack grow towards lower addresses, since there is auto-increment, but not decrement, in the repertoire. It also means you can copy the value at TOS by just accessing *SP, since the stack pointer always points at top of stack.

If you write an operating system, or utilities for others to use, then you may want to check for stack overflow. If you write a specific program for yourself, and just push return links, not large data structures, to the stack, then it's not worth the overhead. If you do get a stack overflow in such a case, you have either severely underestimated the stack space you need, or you have created some bug which causes values to just PUSH, not POP.


Writing macros for the PUSH and POP functions reduce the risk you forget a "+", like in the example above. I frequently used macros for Branch with Link to Stack and ReTurn with Link from Stack, i.e. instructions including the push and branch for a call and pop and branch for a return.

  • Like 2

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...