This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Where to find the stack info used in keil c?

i am not sure if the stack is overflow in my project.
thank a lot!

Parents
  • "What is usage of the five bytes of ISR?"

    Nobody said anything about five bytes. What five bytes are you talking about?

    "And when it enter ISR in main procedure, how do Keil C51 to manager stack? push five bytes directly?"

    If you write your ISR in C, then the compiler generates PUSH/POP instructions to save and restore whatever processor context is required. If you want to "see" it in action, then generate an assembly listing.

Reply
  • "What is usage of the five bytes of ISR?"

    Nobody said anything about five bytes. What five bytes are you talking about?

    "And when it enter ISR in main procedure, how do Keil C51 to manager stack? push five bytes directly?"

    If you write your ISR in C, then the compiler generates PUSH/POP instructions to save and restore whatever processor context is required. If you want to "see" it in action, then generate an assembly listing.

Children
  • one issue

    Those that believe that a global variable is worse than death will have more trouble re stack calculation than normal people. If you transfer more in a call than the registers can hold that affect the stack as well.

    Erik

  • I use glabol variables as normal programming in C51.

    Bug I still have a question about stack while enter ISR, for example:

    normal run in main() that stack base is 0x30H, SP is 0x33, that means 4 bytes in stack as sequence as "0xFF00, 0xFE00". And now it enter ISR, so push "A, B, DHP, DHL, PSW" to stack. So is it SP 0x33 + 5 = 0x38? It seems so strange in my program.

  • And now it enter ISR, so push "A, B, DHP, DHL, PSW" to stack. So is it SP 0x33 + 5 = 0x38? It seems so strange in my program.
    ?

    When an interrupt happens some process is in progress in the main, let us say the following happens
    main: load dptr
    interrupt
    main: load what dptr points to

    Now, if the interrupt uses the dptr (changes its contents) what would happen if it did not save the DPTR at entry and resore it on exit.

    Erik

  • I have solve my problem.

    I compile c source file with parameter "SRC" to get ".SRC" assemble file.

    It pushes ACC, B, DPH, DPL and PSW to stack at the begin of ISR