Search code examples
assemblycompiler-constructionstack-pointer8085

Current state of Stack Pointer in 8085


In Intel 8085 microprocessor, is there any way or instruction exist for find out, to where Stack Pointer currently points to?.


Solution

  • yes, it is possible to find out the value of SP at any time. Here is explanation Using DAD Rp instruction, we can Add Rp with HL pair content. follow the steps below:

    1. For our problem in hand, first we will clear HL content so that after addition of HL with SP, we will left, in HL with the content of Stack Pointer register value.

    Following code will work well:

    LXI H, 0000h; Load HL reg. pair with zero.
    DAD SP ;      Adding HL and SP so that only SP value will be there in HL reg. pair.
    HLT ; Once SP value is there in HL reg. pair, it can be taken any where.