The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+16 votes
2.6k views

Suppose a processor does not have any stack pointer registers, which of the following statements is true?

  1. It cannot have subroutine call instruction
  2. It cannot have nested subroutines call
  3. Interrupts are not possible
  4. All subroutine calls and interrupts are possible
asked in CO & Architecture by Veteran (59.4k points)
retagged by | 2.6k views
+1

option (A) should be "It can not have subroutine call instruction"

reference @ http://gateforum.com/wp-content/uploads/2013/01/CS-2001.pdf

–2
Not having SP means no stack too. So, can we not store the activation records, CS,IP etc values into heap, pass along with parameters(also in stack with some other register holding the current heap pointer and one variable pointing to previous activation record)
0
Could anybody tell which option is the answer please ?and why?
0
"not having stack pointer mean not having stack " its drastic conclusion , please shed some light here.
0

does not have any stack pointer registers

I am thinking can not we use any other register to work as stack pointer registers. or can not we use Heap are to achieve same functionality.

0
@Arjun sir I understand that we can have a subroutine call without having a stack pointer register as the return address gets stored in the stack. But how do we access return address for that subroutine call? And please explain why we cannot have nested subroutine calls.

5 Answers

+20 votes
Best answer
i think ans is B.

because in nested subroutine calls we used to push old subroutines into stack and pointing most recent call with stack pointer.
answered by Loyal (8.3k points)
selected by
–1

@Arjun Sir. Could you please confirm this answer ?

I think, we can call the subroutine but subsequently we can not return back to the next instruction from where we left previously. But at the same time i am also getting that we may call nested subroutine also.

+1
How can we have subroutine call  ??
+7

Subroutine calls can still be possible using fixed memory location. Like one implementation says that we can use the first memory address of subroutine for storing the return address. But, nested calls won't be possible.

I think B is correct

Edit: Providing reference for one such implementation https://en.wikipedia.org/wiki/Subroutine#Jump_to_subroutine

+3

I think Option (A) has to be the answer because when the processor doesn't have any stack pointer register, it should also not have Instruction code written into its instruction set which is needed as an instruction to go forward with implementing subroutine calling, which causes the address of the subroutine to be pushed onto the stack.
The stress must be on the words of option A
"Subroutine call Instruction"

clearly when for any operation I don't have an instruction in instruction set, I cannot implement it.

0
What should be the addressing mode then??
0
He didn't said we don't have any stack but he said we don't have any stack pointer..

I guess without even stack pointer we can still enjoy all utilities of stack although it would be tedious and may be time consuming ...so i think answer should be D.
0
without stack pointer register we can not implement nested interrupts,..so D) can not be the answer
0
I think it should be D. We can implement a stack using an array or a LL and then use this stack for all such operations. Please correct me if I am wrong!
+12 votes

 

 A stack pointer is a small register that stores the address of the last program request in a stack.

And a nested function (or nested procedure or subroutine) is a function which is defined within another function, the enclosing function. So if there is no stack pointer register then No nested subroutine call possible, hence option B is correct.

answered by Veteran (66.6k points)
0
I think option D is also possible. We can implement a stack using an array or a LL and then use this stack for all such operations. Sir, please correct me if I am wrong!
+2 votes

It can not have subroutine call instruction ,

For 8085: Stack pointer is a special purpose 16-bit register in the Microprocessor, which holds the address of the top of the stack.

The most typical use of a hardware stack is to store the return address of a subroutine call. When the subroutine is finished executing, the return address is popped off the top of the stack and placed in the Program Counter register, causing the processor to resume execution at the next instruction following the call to the subroutine.

You push items onto the stack and pop them off. In a microprocessor, the stack can be used for both user data (such as local variables and passed parameters) and CPU data (such as return addresses when calling subroutines).

The actual implementation of a stack depends on the microprocessor architecture. It can grow up or down in memory and can move either before or after the push/pop operations.

Operation which typically affect the stack are:

  • subroutine calls and returns.
  • interrupt calls and returns.
  • code explicitly pushing and popping entries.
  • direct manipulation of the SP register.

http://stackoverflow.com/questions/1464035/what-is-a-stack-pointer-used-for-in-microprocessors

http://en.wikipedia.org/wiki/Call_stack

Necessary steps to implement a subroutine  The stack pointer register must be initiali zed ,preferably at the highest memory lo cation of the R/W memory.  The call instruction should be used in the main program accompanied by the RET i nstruction in the subroutine @ http://www.slideshare.net/safinbiswas/stack-in-microprocessor-8085presantation

 

answered by Loyal (5.9k points)
reshown by
+4
Good explanation. But this says subroutine calls are implemented using stack. This doesn't say without stack we cannot implement subroutine calls, rt?
0

Necessary steps to implement a subroutine  The stack pointer register must be initiali zed ,preferably at the highest memory lo cation of the R/W memory.  .... is not enough sir ??

+1
Nopes. Because that sentence assumes a "stack implementation".

To say A is the answer we have to prove, there is no way to implement subroutine calls without a stack.
+1
so answer is B ??  need more expln ....
0
Yes. And the explanation would be a solution to implement subroutine without a stack. I'll add it.
0
Can't we use any general purpose register as stack pointer register, then we have to manually perform push and pop operation?
0
I think answer should be B) because we won't be able to use stack but "link register" is another option which can store single return address
0
@Arjun sir,

Why are we having b as answer and not a?

Please confirm if b is the correct answer.
0

@rahul sharma 5 

 

 A stack pointer is a small register that stores the address of the last program request in a stack.

A nested function (or nested procedure or subroutine) is a function which is defined within another function, the enclosing function.  It means if we don't store last program request then how nested function works ?

So if there is no stack pointer register then No nested subroutine call possible, hence option B is correct.

0 votes
I think we can always use stack using a memory location for stack pointer instead of using register. Ans is D.
answered by (37 points)
–1 vote

Explanation: Stack pointer register hold the address of top of stack, which is the location of memory at which CPU should resume its execution after servicing some interrupt or subroutine call.

So if SP register is not available then no subroutine call instructions are possible. So (A) is correct option.

http://quiz.geeksforgeeks.org/gate-gate-cs-2001-question-10/

answered by Junior (693 points)
0

So if SP register is not available then no subroutine call instructions are possible. So (A) is correct option.

How nesting then work if you don't save address of next instruction ?

 

0
@Bikram sir what is wrong with option (c)?


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

34,786 questions
41,762 answers
118,950 comments
41,409 users