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

Stack initialization with constant

Doe Keil IDE support initializing stack space with a constant? For example with a #define. If not, please does someone have ARM Cortex M3/M4 assembler code to do that and where should it be located? For example in startup*.s prior to the branch to main?

Parents
  • OK so the Reset Handler now looks like this,

    ; Reset handler
    Reset_Handler    PROC
                     EXPORT  Reset_Handler             [WEAK]
            IMPORT  SystemInit
            IMPORT  __main
    
                     LDR     R0, =SystemInit
                     BLX     R0
    
                     LDR     R0, =Stack_Mem            ;Added
                     LDR     R1, =Stack_Size           ;
                     LDR     R2, =0xCCCCCCCC           ;
    Fill             STR     R2, [R0], #4              ;
                     SUBS    R1,#4                     ;
                     BNE     Fill                      ;
    
                     LDR     R0, =__main
                     BX      R0
                     ENDP
    


    It works! Thanks for your help. I have one more question.

    I checked the fill worked by getting the STACK address from the *.map file. Why doesn't typing "STACK" or "Stack_Mem" etc. directly into the "Memory 1" Memory Window work?

    In other words, how can I use a symbolic name in the IDE debugger to view the stack content?

Reply
  • OK so the Reset Handler now looks like this,

    ; Reset handler
    Reset_Handler    PROC
                     EXPORT  Reset_Handler             [WEAK]
            IMPORT  SystemInit
            IMPORT  __main
    
                     LDR     R0, =SystemInit
                     BLX     R0
    
                     LDR     R0, =Stack_Mem            ;Added
                     LDR     R1, =Stack_Size           ;
                     LDR     R2, =0xCCCCCCCC           ;
    Fill             STR     R2, [R0], #4              ;
                     SUBS    R1,#4                     ;
                     BNE     Fill                      ;
    
                     LDR     R0, =__main
                     BX      R0
                     ENDP
    


    It works! Thanks for your help. I have one more question.

    I checked the fill worked by getting the STACK address from the *.map file. Why doesn't typing "STACK" or "Stack_Mem" etc. directly into the "Memory 1" Memory Window work?

    In other words, how can I use a symbolic name in the IDE debugger to view the stack content?

Children