answersLogoWhite

0


Best Answer

No. The program counter must be stored in a dedicated register. The stack is in working memory and you cannot operate on working memory; all values must be moved into a register in order to operate upon them. It makes no sense to move a program counter in and out of memory unless performing a context switch and you can't use a stack for context switching; a priority queue must be used for this. Keep in mind that the address of the top of the stack has to be moved in and out of its register during a context switch. It doesn't make sense to load the stack register from a priority queue before you can determine where the program counter value is. It's easier to keep all state information in the same place in the priority queue where it belongs.

User Avatar

Wiki User

7y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

No.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can the program counter be eliminated by using the top of the stack as a program count?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is difference between stack pointer and program counter?

Both of them are pointers, but otherwise they are completely unrelated. The former points to the current position of the stack, the latter points to the current instruction of the program.


Why must the stack pointer be initialized at the beginning of every program?

Because the stack pointer marks the top of the stack. If it is not initialised, it is not possible to determine where the next stack frame will go.


Code palindrome in c using queue and stuck?

/** C Program to Check String is Palindrome using Stack.*/#include #include void push(char);char pop();char stack[100];int top = -1;void main(){char str[100];int i, count = 0, len;printf("Enter string to check it is palindrome or not : ");scanf("%s", str);len = strlen(str);for (i = 0; i < len; i++){push(str[i]);}for (i = 0; i < len; i++){if (str[i] == pop())count++;}if (count == len)printf("%s is a Palindrome string\n", str);elseprintf("%s is not a palindrome string\n", str);}/* Function to push character into stack */void push(char c){stack[++top] = c;}/* Function to pop the top character from stack */char pop(){return(stack[top--]);}


Stack c language program of palindrome?

what ever you assume


What is the purpose of the program stack?

Its main use is to store local variables, arguments and return address each time a function is called.When your program calls a function the following happen :- The function arguments are put on the stack- The current instruction pointer is put on the stack- The program jumps to the start of the function- Space is allocated on the stack to hold local variables- The function executes- The space holding local variables is de-allocated- The instruction pointer is restored and removed from the stack (we are now leaving the function and resuming the calling procedure)- The arguments are removed from the stack

Related questions

What is the difference between stack pointer and program counter?

The stack pointer keeps track of the top of the stack used by the current thread. The program counter keeps track of the next instruction in a program. Both are registers and both store a memory address.


What is difference between stack pointer and program counter?

Both of them are pointers, but otherwise they are completely unrelated. The former points to the current position of the stack, the latter points to the current instruction of the program.


What does a process include?

A process contains a program counter, stack, heap, data section and text section.


Why are programme counter and stack pointer register 16 bit registers?

The program counter (PC) and stack pointer (SP) registers are 16-bit registers in the 8085 and in the 8086/8088 because that is how Intel designed the processors.


Which CPU register holds address for memory?

The program counter (PC) and the stack pointer (SP).


Why you call programmcounter stack pointer as special purpose resistors?

The Program Counter and Stack Pointer registers are called special purpose registers because they can not be used arbitrarily; they are, well, special. You cannot, for instance, load a new value into the Program Counter and blithely continue, that action would cause an unconditional jump. Also, the Program Counter is automatically incremented by the size of the instruction, so you can not just put something in it and expect its value to persist. Similarly, you cannot load a new value into the Stack Pointer without losing the entire stack context that you are in.


What will happen when pop instruction is executed?

The top of stack to copied to the specified register and the stack pointer is incremented by 2. A special form of POP, RET, has the program continuing with the popped address in the program counter, i.e. a return from subroutine or function call.


Why program counter and stack pointer is 16- bit?

Because that's how Intel designed it. Even though the 8085 is an 8-bit computer, the program counter and stack pointer are 16 bits wide in order to support the address bus, which is also 16 bits wide. In the case of the 8086/8088, the program counter and stack pointer are still 16 bits wide, even though the address bus is 20 bits wide, because the 8086/8088 adds segmentation through the 16 bit segment register which is left shifted by 4.


Why stack pointer is 16- bit register?

Program Counter( PC)stores the 16-bit memory address of the next instruction to be fetched. Stack Pointer (SP)stores the address of a memory location which is used as a stack.


What is the function of the stack counter?

Its not a stack counter - its a stack pointer. The stack pointer is a register that points to the top of the stack. In the Intel configuration, it points to the next item to be popped off the stack. To push an item requires that the stack pointer be decremented first, and then the item is written. The inverse operation - the pop - requires read then increment.


How ISR is serviced?

when interrupt occurs, the program counter content will stores into stack, an PC will load interrupt address for next instruction execution. ofter completion ISR process PC will retrieves the stack values and execution will be continued.


Difference between a counter and a register?

A register can hold data, and it can be used for temporary storage or, in the case of an accumulator, it can participate in arithmetic or logical operations. A counter is a special case of a register. Usually, it can only be loaded, stored, or incremented, or used for the stack or as the program counter.