Questions tagged [stack-pointer]

Anything related to stack-pointer operations. The stack pointer (SP) is a special purpose register found on most microprocessors or microprocessors cores (such as those inside microcontrollers or multicore CPUs) used to hold the address of the top of the hardware stack.

Anything related to stack-pointer operations. The stack pointer (SP) is a special purpose register found on most microprocessors or microprocessor cores (such as those inside microcontrollers or multicore CPUs) used to hold the address of the top of the hardware stack.

The hardware stack is an area of the main memory which is managed directly by the μP using a LIFO (Last-In First-Out) discipline. The assembly programmer can operate the stack using special instructions like PUSH and POP. The processor automatically uses the stack for some of its operations, most typically for keeping track of subroutine calls.

See Wikipedia on what is an hardware stack.

11 questions
9
votes
1 answer

Main Stack Pointer(MSP) vs Process Stack Pointer(PSP)

I was reading the STM32 Programming manual and somewhere on "page 18 " i see these two kind of stack pointers. I always think that there is only ONE stack and therefore only ONE stack pointer to that exists in MCUs and now i'm confused of what these…
Amin Rostami
  • 889
  • 3
  • 12
  • 29
6
votes
1 answer

What is meaning and significance of locally decrementing SP (Stack Pointer)?

What is meaning of line "SP (Stack Pointer) can be decremented locally" *I am not asking the answer of the whole question in the image.
Rajan
  • 171
  • 5
2
votes
1 answer

STM32F103: Custom bootloader weird behaviour with stack pointer

So, I am trying to use this USB mass storage bootloader for the STM32F103C8 (64kB flash): https://github.com/sfyip/STM32F103_MSD_BOOTLOADER To compile .hex files for it, I've already set the flash origin to 0x8004000 and the vector table offset to…
sx107
  • 945
  • 5
  • 24
2
votes
1 answer

When does the stack pointer get copied from flash to SP on startup?

I'm trying to track down a problem on a MKV31F256 micro. The firmware immediately jumps to the hard fault handler on startup. I'm able to set a breakpoint on the first assembly instruction in the reset handler and look at memory and the registers,…
CurtisHx
  • 995
  • 7
  • 12
1
vote
1 answer

bootloaders "reset memory mapping"

im looking into bootloaders and how they work this picture from application note by atmel for their SAM series bootloader "AP-Note_AT04189" so Stack pointer and reset? Stack pointer is an address of the first instruction in the Flash memory right?…
Hasan alattar
  • 487
  • 5
  • 16
1
vote
1 answer

What happens If the interrupt occurs during the execution of HALT instruction?

Consider the following program segment on a hypothetical processor . I have this question in my course CS201. Suppose this processor has 32 bits Load/Store operations, ALU operations is 16 bits and Branch instruction is 16 bits. Program has been…
1
vote
3 answers

Why is MSP430's Stack Poniter(SP) always alligned to even address?

While I was reading through the MSP430's User's guide, I came to know that its stack pointer is alligned to even address. (Read Pg.189 of http://www.ti.com/lit/ug/slau208m/slau208m.pdf) Why is it so ? Why is the stack pointer alligned to even…
robomon
  • 913
  • 1
  • 12
  • 21
0
votes
2 answers

8085 : Storing data in stack

In 8085 whatever address the stack pointer holds, we always start storing bytes from one less than this address . Eg. If SP holds 2008H. We will store 16-bit data at 2007 and 2006H. Why don't we store at 2008H itself? Aren't we wasting a memory…
Urooj
  • 73
  • 1
  • 4
0
votes
4 answers

ZiLOG Z80 Stack Pointer Location in Memory?

I am trying to design a board for a Z80 based computer, and am having trouble designing the memory map. I have found that the Program Counter defaults to address #0000, but I cannot find where the Stack Pointer defaults to. Is it also #0000? Am I…
LukeIsMe
  • 1
  • 2
0
votes
1 answer

Confusion on pop for recursive assembly code

I'm confused on what happens during POP. When POP LR happens does that change the PC to the location of LR, which would be sumi. If it does take it back to sumi wouldn't that just take the recursion even further? C++: int sumi(int n) { if(n == 0) …
stumped
  • 145
  • 2
  • 7
-3
votes
2 answers

Manually storing the stack pointer rather than using push and pop (Assembly)

What will be the instruction sequence that implements PUSH R4? A: SUB SP, SP, #4 STR R4, [SP, #0] B: STR R4, [SP, #0] SUB SP, SP, #4 C: ADD SP, SP, #4 STR R4, [SP, #0] D: STR R4, [SP, #0] ADD SP, SP, #4 E: All of the above are possible The…
stumped
  • 145
  • 2
  • 7