简体   繁体   English

在MSP430组件中定义阵列的位置

[英]Defining Location of an Array in MSP430 Assembly

I can define an array in MSP430 assembly by: 我可以通过以下方式在MSP430组件中定义数组:

 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. 但是,当我调试汇编代码时,我意识到Code Composer Studio的TI编译器将阵列放置在Boot Memory部分中。 With that reason, array elements are read-only. 因此,数组元素是只读的。 But I want to edit the contents of the array (ie, changing the order of the elements during sorting). 但是我想编辑数组的内容(即在排序过程中更改元素的顺序)。 To do that, I tried org keyword but it did not help. 为此,我尝试了org关键字,但没有帮助。 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 (eg, information memory, RAM, etc.)? 如何定义数组的位置,以便编译器将数组放置到我指示的位置,该位置是内存地址空间(例如信息内存,RAM等)的可编辑段?

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 eg RAM space and the code would be copied to the FLASH memory. 当您将程序(和阵列)传输到芯片时,该阵列将被复制到例如RAM空间中,并且代码将被复制到闪存中。 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. 给MCU重新上电后,代码将存在,但阵列将消失。

A better solution would be to copy the array from the read only code space into the RAM after your programm started. 更好的解决方案是在程序启动后将阵列从只读代码空间复制到RAM中。 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. 有一个用于初始化变量的.data节和一个用于未初始化变量存储器的.bss节,可用于在引导过程运行时自动将修订程序数据复制到易失性存储器中。

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; 您可能也对《 MSP430汇编语言工具用户指南》 (PDF)感兴趣:请参见第2.3、3.1.1、3.5和8.5.5节; Keywords: runtime relocation, load address, run adress, .text, .data, .bss, program sections 关键字:运行时重定位,加载地址,运行地址,.text,.data,.bss,程序段

I managed to place the array to the RAM finally by using .data keyword as: 我最终通过使用.data关键字将数组最终放置到RAM中:

            .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. 现在,TI编译器将阵列放置到RAM中,我可以轻松地编辑内容。 @CL and @peter-paul-kiefer, thank you for your help. @CL和@ peter-paul-kiefer,谢谢您的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM