Reputation: 161
I can define an array in MSP430 assembly by:
array .byte 00000101b, 00000100b, 00000011b, 00000010b, 00000001b
lastelement
But when I debug my assembly code, I realize that TI compiler of Code Composer Studio places the array to the Boot Memory section. With that reason, array elements are read-only. But I want to edit the contents of the array (i.e., changing the order of the elements during sorting). To do that, I tried org keyword but it did not help. How can I define the location of the array so that compiler places the array to the location I indicate which is an editable segment of the memory address space (e.g., information memory, RAM, etc.)?
Upvotes: 0
Views: 2800
Reputation: 161
I managed to place the array to the RAM finally by using .data keyword as:
.data
array .byte 00000101b, 00000100b, 00000011b, 00000010b, 00000001b
lastelement
Now, the TI compiler places the array to the RAM and I can edit the contents easily. @CL and @peter-paul-kiefer, thank you for your help.
Upvotes: 0
Reputation: 2124
I do not know if it is possible to link data in a volatile memory adress space. But for me it makes no sense. When you transfer your program (and the array) to the chip then the array would be copied to the e.g. RAM space and the code would be copied to the FLASH memory. But what happens when you switch off the power? After repowering the MCU, the code will be there but the array will have been gone.
A better solution would be to copy the array from the read only code space into the RAM after your programm started. There is a section .data for initialized variables and a section .bss for uninitialize variable memory which can be used for automatically copying fix programm data to the volatile memory while the boot process is running.
You might also be interested in the MSP430 Assembly Language Tools User's Guide (PDF): see sections 2.3, 3.1.1, 3.5 and 8.5.5; Keywords: runtime relocation, load address, run adress, .text, .data, .bss, program sections
Upvotes: 1