Stack Overflow Summary

Publisher:温暖的微风Latest update time:2015-09-18 Source: eefocusKeywords:Stack overflow Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1. The stack is not big enough
2.  Is there a statement in the subroutine that directly or conditionally jumps out of the subroutine body? If so, a stack overflow will occur after running the subroutine N times
3. The page is not set properly for program jumps, table lookups, etc.
4. Different uses of GOTO and CALL instructions In the PIC assembly program, the CALL and GOT0 instructions are used in different places. CALL is used to call a subroutine, and after calling the subroutine, it returns to the program before the call; while GOTO is an unconditional transfer, that is, it enters another state from this state without returning. In order to make the program more readable and the process clearer and more reasonable, the program usually adopts modular programming, that is, the program is divided into different subroutines according to function, and the main program is quite simple, and only the CALL instruction is used to call the subroutine. Since the stack of the PIC microcontroller is limited, the GOTO instruction cannot be used endlessly in the program, otherwise it will cause the stack to overflow and the program cannot run normally. But sometimes, such as when the program branches, the GOTO instruction has to be used. For the PICl6F7x series of microcontrollers, when a program branches, it can only be judged by the Z bit or C bit of the STATUS register. At this time, in the first of the two situations, the GOTO instruction must be used to transfer; otherwise, after executing the first situation, the second situation will be executed immediately. The program is as follows: BTFSS STATUS, Z GOTO A GOTO B When jumping to A, the GOTO instruction must be used; otherwise, after executing this statement, GOTO B will be executed immediately. In this way, no matter what the value of Z is, the program will jump to B. For GOT0 B, the GOTO instruction does not need to be used. In the above case, since GOTO only jumps within the subroutine, the internal loop of the small program occupies a small number of stack levels, so it is feasible to use the GOTO instruction. However, when using the GOTO instruction in a large program, it may not be possible to return to the next instruction before the call. Therefore, the author recommends that when using assembly language for programming, the program should be
Keywords:Stack overflow Reference address:Stack Overflow Summary

Previous article:Network port literacy 2: Simple analysis of the composition principle of Mac and Phy
Next article:In-depth analysis of local variables and global variables in MCU compiler

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号