Hi, i want to build a kind of soundbox-toy. It has grown so i need a few more extra bytes of RAM memory. Unfortunately the printed circuit board is ready. So i can not add some external memory.
It is allowed to modify the startup.s file? Reducing stack to get a little more memory?
How to test out the limits? Can i do this at all? I'am worried a little, all this stuff in the startup file looks very complicated to me. Afraid of doing the wrong things!
I'am using a ADuC7026 it has only 8 kByte of RAM memory. Here's my startup.s file
/***********************************************************************/ Mode_USR EQU 0x10 Mode_FIQ EQU 0x11 Mode_IRQ EQU 0x12 Mode_SVC EQU 0x13 Mode_ABT EQU 0x17 Mode_UND EQU 0x1B Mode_SYS EQU 0x1F I_Bit EQU 0x80 /* when I bit is set, IRQ is disabled */ F_Bit EQU 0x40 /* when F bit is set, FIQ is disabled */ UND_Stack_Size EQU 0x00000004 SVC_Stack_Size EQU 0x00000004 ABT_Stack_Size EQU 0x00000004 FIQ_Stack_Size EQU 0x00000004 IRQ_Stack_Size EQU 0x00000080 USR_Stack_Size EQU 0x00000400 AREA STACK, DATA, READWRITE, ALIGN=2 DS (USR_Stack_Size+3)&~3 ; Stack for User/System Mode DS (SVC_Stack_Size+3)&~3 ; Stack for Supervisor Mode DS (IRQ_Stack_Size+3)&~3 ; Stack for Interrupt Mode DS (FIQ_Stack_Size+3)&~3 ; Stack for Fast Interrupt Mode DS (ABT_Stack_Size+3)&~3 ; Stack for Abort Mode DS (UND_Stack_Size+3)&~3 ; Stack for Undefined Mode Top_Stack: // MMR definitions MMR_BASE EQU 0xFFFF0000 ; MMR Base Address REMAP_OFFSET EQU 0x0220 PREMAP_OFFSET EQU 0x0224 POWKEY1_OFFSET EQU 0x0404 POWCON_OFFSET EQU 0x0408 POWKEY2_OFFSET EQU 0x040C PLL_SETUP EQU 1 PLLCFG_Val EQU 0x00000000 // alter Wert war 0x00000001 GPIO_SETUP EQU 1 GPIOBASE EQU 0xFFFFF400 GP0CON_Val EQU 0x00000000 GP1CON_Val EQU 0x00000000 GP2CON_Val EQU 0x00000000 GP3CON_Val EQU 0x00000000 GP4CON_Val EQU 0x00000000 $IF (RAM_INTVEC) // Exception Vector Area in RAM AREA VECTORS, DATA, AT 0x00010000 DS 64 $ENDIF // Startup Code must be linked at address which it expects to run. AREA STARTUPCODE, CODE, AT 0x00080000 PUBLIC __startup EXTERN CODE32 (?C?INIT) __startup PROC CODE32 // Pre-defined interrupt handlers that may be directly // overwritten by C interrupt functions EXTERN CODE32 (Undef_Handler?A) EXTERN CODE32 (SWI_Handler?A) EXTERN CODE32 (PAbt_Handler?A) EXTERN CODE32 (DAbt_Handler?A) EXTERN CODE32 (IRQ_Handler?A) EXTERN CODE32 (FIQ_Handler?A) // Exception Vectors // Mapped to Address 0. // Absolute addressing mode must be used. Vectors: LDR PC,Reset_Addr LDR PC,Undef_Addr LDR PC,SWI_Addr LDR PC,PAbt_Addr LDR PC,DAbt_Addr NOP /* Reserved Vector */ LDR PC,IRQ_Addr LDR PC,FIQ_Addr Reset_Addr: DD Reset_Handler Undef_Addr: DD Undef_Handler?A SWI_Addr: DD SWI_Handler?A PAbt_Addr: DD PAbt_Handler?A DAbt_Addr: DD DAbt_Handler?A DD 0 /* Reserved Address */ IRQ_Addr: DD IRQ_Handler?A FIQ_Addr: DD FIQ_Handler?A // Reset Handler Reset_Handler: // Setup PLL IF (PLL_SETUP != 0) LDR R0, =MMR_BASE MOV R1, #0x01 STR R1, [R0,#POWKEY1_OFFSET] MOV R1, #PLLCFG_Val STR R1, [R0,#POWCON_OFFSET] MOV R1, #0xF4 STR R1, [R0,#POWKEY2_OFFSET] ENDIF ; PLL_SETUP // Setup Pins IF (GPIO_SETUP != 0) ADR R10, GPIO_CFG /* Pointer to GPIO CFG */ LDMIA R10, {R0-R5} /* Load GPIO Configuration */ STMIA R0, {R1-R5} /* Store GPxCON */ B GPIO_END GPIO_CFG: DD GPIOBASE DD GP0CON_Val DD GP1CON_Val DD GP2CON_Val DD GP3CON_Val DD GP4CON_Val GPIO_END: ENDIF ; GPIO_SETUP // Setup Stack for each mode LDR R0, =Top_Stack // Enter Undefined Instruction Mode and set its Stack Pointer MSR CPSR_c, #Mode_UND|I_Bit|F_Bit MOV SP, R0 SUB R0, R0, #UND_Stack_Size // Enter Abort Mode and set its Stack Pointer MSR CPSR_c, #Mode_ABT|I_Bit|F_Bit MOV SP, R0 SUB R0, R0, #ABT_Stack_Size // Enter FIQ Mode and set its Stack Pointer MSR CPSR_c, #Mode_FIQ|I_Bit|F_Bit MOV SP, R0 SUB R0, R0, #FIQ_Stack_Size // Enter IRQ Mode and set its Stack Pointer MSR CPSR_c, #Mode_IRQ|I_Bit|F_Bit MOV SP, R0 SUB R0, R0, #IRQ_Stack_Size // Enter Supervisor Mode and set its Stack Pointer MSR CPSR_c, #Mode_SVC|I_Bit|F_Bit MOV SP, R0 SUB R0, R0, #SVC_Stack_Size // Enter User Mode and set its Stack Pointer MSR CPSR_c, #Mode_USR MOV SP, R0 // Enter the C code LDR R0,=?C?INIT TST R0,#1 ; Bit-0 set: main is Thumb LDREQ LR,=exit?A ; ARM Mode LDRNE LR,=exit?T ; Thumb Mode BX R0 ENDP PUBLIC exit?A exit?A PROC CODE32 B exit?A ENDP PUBLIC exit?T exit?T PROC CODE16 B exit?T ENDP END
Open your project options.
Select page 'Listing'
Turn on 'Linker Listing'
Make sure that you have 'Callgraph' checked.
Build project and look in your output directory for a file named '<project>.htm'.
However, as mentioned before, it is only a static call graph. It will not help you if you make use of recursive functions.