The software stack is implemented by you through coding. You allocate a block in memory as the stack area and use a variable as the stack pointer.
Software stack: It can also be called user stack. It can be defined in internal or external RAM. It is a dedicated data stack created by the user for a task, which is separated from the data area of the system stack. It can save any registers and status words that the user wants to save.
The software stack of MPLAB C18 is an upward-growing stack data structure. The compiler puts function parameters and local variables of the auto storage class into the software stack. The software stack is different from the hardware stack used by PICmicro MCUs to save function call return addresses.
The stack pointer (FSR1) always points to the next available stack address. MPLAB C18 uses FSR2 as a frame pointer, which allows fast access to local variables and parameters. When a function is called, its stack-based parameters are pushed onto the stack in right-to-left order before the function is called. On entry to a function, the leftmost function parameter is at the top of the software stack.
The frame pointer points to the address on the stack that separates stack-based parameters from stack-based local variables. Stack-based parameters are located below the frame pointer, while stack-based local variables are located above the frame pointer. When a C function is first entered, the called function pushes the value of FSR2 onto the stack and copies the value of FSR1 to FSR2, thereby saving the calling function's scene and initializing the current function's frame pointer. The total length of the function's stack-based local variables is then added to the stack pointer, and stack space is allocated for these variables. Stack-based local variables and stack-based parameters are referenced based on their offset relative to the frame pointer.
Previous article:PIC Basics
Next article:16F876 controlled electric bicycle drive system source code
Recommended ReadingLatest update time:2024-11-16 08:38
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- [NXP Rapid IoT Review] Offline Compilation and Testing Summary
- [GD32F350/GD32E103] Build VSF-based WebUSB DFU using open source toolchain
- How to determine whether the power supply needs a PFC circuit?
- RFMD and Qorvo prototype boards vs. honeycomb heat sinks
- Is there any big guy who does MEMS process research and development? Please guide me
- Question about LED flashing (newbie question)
- Learn about vehicle-to-everything (V2X) technology in one article
- Evaluation of the domestic FPGA Gaoyun GW1N-4 series development board - Software Part 1
- R329 Zhouyi AIPU environment construction and simulation practice
- Current sensor circuit inquiry?