Why initialize stack pointer




















The stack pointer is a bit register having a memory address. For example, when the SP contents are of FC78H, then the address locations are interpreted as below. So, SP contents indicate the uppermost locations in the stack which means that it specifies memory location having the smallest address with useful data. It can be illustrated as:. The stack is generally a reversed area in RAM to store the information. Anywhere in the memory map, a stack can be initialized, but usually, it will be initialized at the higher memory location to get rid of any programming interface.

Coming to , the initialization of stack is instructed as. LXI SP is a bit state which loads a bit address into stack register. The initialization of the stack pointer can be done by Load Stack Pointer. Both the operations work together with register pairs following the LIFO principle.

The stack pointer is mainly used as a memory pointer which specifies to the memory location that read and write memory to that location.

As the general usage of the stack is to hold automatic variables and parameters that are across function calls. PC and SP are utilized to store the memory locations and as the previous location address is bits and so stack pointers are also of bits. The stack grows down, but this code looks rather weird.

Yeah, it is actually a simplification of the "real assembly" made by my professor in order to understand the basics. Show 6 more comments. Active Oldest Votes. Improve this answer. Add a comment. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Explaining the semiconductor shortage, and how it might end. Does ES6 make JavaScript frameworks obsolete? Jan 6, - PM. Fivestar widget 1 2 3 4 5.

So can anybody help me answering this question, an image or an assembly example would be nice :. Level: Raving Lunatic. Posts: View posts. Posted by Brutte : Mon. Log in or register to post comments Top.

Level: Moderator. Location: using avr-gcc in Finchingfield, Essex, England. Posted by clawson : Mon. For a clearer understanding for me, have I understood you correctly? Posted by js : Mon.



0コメント

  • 1000 / 1000