edited by
691 views
1 votes
1 votes

After executing one CALL instruction, the content of PC is decremented by $8$ ( for storing PC and flag register content on stack memory)

Consider the following

Memory address                 Instruction

  • $2502$                      :  MOV A,$56$

 

  • $2503$                      :ADD A,B

 

  • $2504$                      :CALL $8500$

 

  • $2506$                      :DCR B

 

  • $2508$                      : SUB A, B


            ..

            ..

            ..

            ..

  • $8500$                             :MOV C,$85$

 

  • $8502$                           :ADD D,C


                                                       ..
         
                                                       ..

                                                      ...

                                                    RET

In the above program,all values are given in decimal and A,B,C,D are processing registers. After executing 'RET"  , processsor POPs the stack content to PC and flag register. Let content of SP be $6950$ when PC content is $2503$

content of SP when PC reaches $2508$ is ____________________

edited by

1 Answer

0 votes
0 votes

Some point answering this question

  • SP or stack pointer resides in memory
  • After CALL, there is a return instruction
  • SP contain topmost address of stack, which may work as temporary memory
  • PC contain address of next instruction.

Now, content of SP be $6950$ when PC content is $2503$

$2503$ address contain addition of two registers value A,B  , So, no need of SP here

Next $2504$ is CALL instruction, and SP requires here, and after  CALL instruction, there is a return instruction.

So, In return instruction Stack again become empty and hold address of $6950.$

And next $2506$ is a register operation, so no need of SP.

And atlast PC points to  $2508$ , SP still in $6950.$

for more:https://www.geeksforgeeks.org/difference-call-jump-instructions/

 

Related questions

2 votes
2 votes
1 answer
1
2 votes
2 votes
1 answer
3