in CO and Architecture edited by
701 views
1 vote
1 vote

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 ____________________

in CO and Architecture edited by
by
701 views

4 Comments

6950 ??
0
0
Yes can u please explain
0
0
stack pointer points to top of stack..during call instruction PC will be pushed to stack, now lets say stack pointer become 'a'... after return top of stack will be popped out and stack pointer will again point to its previous location i.e 6950
0
0
the explanation had 6950+8-8 = 6950

what have they done

and not very clear with the explanation
0
0

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