Kasun Hewage wrote:
It seems, this can not be done or no point of doing it in MSP430 MCUs
because they are Von Neumann architecture MCUs. Would you be able to
tell me that how can I gain an optimized RAM usage when dealing with
constant strings.
Take a look at list file for simple example:
__attribute__((noreturn))int main()
{
WDTCTL = WDTPW;
send_string("Hello I am Kasun", 17);
for(;;);
}
.text
143 .LC0:
144 0000 4865 6C6C .string "Hello I am Kasun"
144 6F20 4920
144 616D 204B
144 6173 756E
144 00
145 .section .text.main,"ax",@progbits
146 .p2align 1,0
147 .global main
149 /***********************
150 * Function `main'
151 ***********************/
152 main:
153 .LFB4:
154 .LSM10:
155 /* prologue: frame size = 0 */
156 .L__FrameSize_main=0x0
157 .L__FrameOffset_main=0x4
158 0000 3140 0000 mov #(__stack-0), r1
159 0004 0441 mov r1,r4
160 /* prologue end (size=3) */
161
162 .LSM11:
163 0006 B240 005A mov #llo(23040), &0x0120
163 2001
164 .LSM12:
165 000c 3E40 1100 mov #llo(17), r14
166 0010 3F40 0000 mov #.LC0, r15 ; <--- here
167 0014 B012 0000 call #send_string
168 .LSM13:
169 .L9:
170 0018 FF3F jmp .L9
171 .LSM14:
172
173 /* epilogue: empty, noreturn function*/
174 .LFE4:
176
177 /********* End of function ******/
As you can see, string located in .text region and send_string gets pointer
directly to this location (; <--- here), with no intermediate copy to ram.
--
Regards,
Sergey A. Borshch mailto: [email protected]
SB ELDI ltd. Riga, Latvia