Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly MSP432 ARM-使用程序集声明常量数组_Assembly_Microcontroller_Flash Memory_Code Composer_Msp432 - Fatal编程技术网

Assembly MSP432 ARM-使用程序集声明常量数组

Assembly MSP432 ARM-使用程序集声明常量数组,assembly,microcontroller,flash-memory,code-composer,msp432,Assembly,Microcontroller,Flash Memory,Code Composer,Msp432,如何仅使用程序集而不是C声明flash中的常量数组? 我相信,问题说明了一切。除了在汇编代码本身中之外,我还希望访问并迭代该常量值数组 我使用的是CodeComposer Studio,一个MSP432 相比之下,我知道如何访问RAM,因为我知道这些地址存在于何处,我的代码可以随意使用它们。因此,我可以这样做: ;declare 1st RAM address: FIRST .field 0x20000000,32 ;use it: LDR R1,FIRST LDRB R0

如何仅使用程序集而不是C声明flash中的常量数组?

我相信,问题说明了一切。除了在汇编代码本身中之外,我还希望访问并迭代该常量值数组

我使用的是CodeComposer Studio,一个MSP432

相比之下,我知道如何访问RAM,因为我知道这些地址存在于何处,我的代码可以随意使用它们。因此,我可以这样做:

;declare 1st RAM address:
FIRST   .field 0x20000000,32

;use it:
    LDR R1,FIRST
    LDRB R0,[R1]
;etc.
或者,如果我正在访问GPIO,我知道具体的输入地址:

但我需要来自flash的值,连续的,来自已知地址的,如上所述

更新:

       .thumb             
       .text             
       .align  2       

;my issue or question is about this section (I think)
;don't know how or what to put here
;to declare a continguous block of
;addresses in flash, containing
;specific values

;i dont want to load just the values,
;i need to know how to start at a certain
;address
; i.e. i want to mimic an array,
; but in flash.

;i know how to initialize and mimic an
;array in RAM.

      .global main    
      .thumbfunc main  

main: .asmfunc 

mainloop
    ;code here that starts at
    ;first address in flash
    ;containing first value
    ;and reads it into a register
    ;
    ;the code isn't the problem.
    ;i know how to do this part.

    B  mainloop

    .endasmfunc     
    .end           
更多更新 我在CodeComposer中为MSP432创建了一个基本的C项目。 在main()中,我有:

当我调试它时,结果就像我想要的一样-flash中的一系列常量,在本例中位于代码“main()”之后,从flash地址
0x000005D0
开始。然后存储在每个连续位置的数据就是我指定的int值

但我想在直汇编中实现,而不是C

构建输出(将显示我想象中的工具链)是:

****构建项目00.static.global.const.array.of.ints的配置调试****
/opt/ti/ccsv8/utils/bin/gmake-k-j 2 all-O
生成文件:“../main.c”
调用:ARM编译器
“/opt/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.2.LTS/bin/armcl”-mv7M4--code_state=16--float_support=FPv4SPD16-me--include_path=“/opt/ti/ccsv8/ccs_base/arm/include”--include_path=“/home/devchu/devchu/Development/ti.robotics/tirslk_迷宫1_00/00.static.global.const.ints”--include_path=“/opt/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.2.LTS/include”-advice:power=all--define=u msp432; p401r_uu--define=ccs-g--gcc--diag_warning=225--diag_wrap=off display_error_number--abi eabi=eabi--preproc_with_compile--preproc--preproc_dependency=main.d_raw../main.c”
“./main.c”,第3行:警告#179-D:变量“somearr”已声明但从未引用
完工建筑:“../main.c”
构建目标:“00.static.global.const.array.of.int.out”
调用:ARM链接器
“/opt/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.2.LTS/bin/armcl”-mv7M4--code_state=16--float_support=FPv4SPD16-me--advice:power=all--define=u MSP432P401R--define=ccs-g--gcc--diag-warning=225--diag-wrap=off display_error_number--abi eabi-z-m”00.static.global.const.const.array.of.ints.map--堆大小=1024堆栈大小=512-i“/opt/ti/ccsv8/ccs\u base/arm/include“-i”/opt/ti/ccsv8/tools/compiler/ti-cgt-arm\u 18.1.2.LTS/lib“-i”/opt/ti/ccsv8/tools/compiler/ti-cgt-arm\u 18.1.2.LTS/include”--重读\u libs--diag\u wrap=off--显示错误\u编号--警告\u节--xml\u link info=“00.static.global.const.array.of.ints\u linkInfo.xml”--rom模型-o”00.static.global.const.array.of.ints.out.“/main.obj.”/startup\u msp432p401r\u ccs.obj.“/system\u msp432p401r.obj”“../msp432p401r.cmd”-llibc.a
备注#10371-D:(ULP 1.1)未检测到使用低功耗模式状态更改指令
备注#10372-D:(ULP 4.1)在此项目中检测到未初始化的端口1。建议初始化所有未使用的端口,以消除未使用引脚上的浪费电流消耗。
备注#10372-D:(ULP 4.1)在此项目中检测到未初始化的端口2。建议初始化所有未使用的端口,以消除未使用引脚上的浪费电流消耗。
备注#10372-D:(ULP 4.1)在此项目中检测到未初始化的端口3。建议初始化所有未使用的端口,以消除未使用引脚上的浪费电流消耗。
备注#10372-D:(ULP 4.1)在此项目中检测到未初始化的端口4。建议初始化所有未使用的端口,以消除未使用引脚上的浪费电流消耗。
备注#10372-D:(ULP 4.1)在此项目中检测到未初始化的端口5。建议初始化所有未使用的端口,以消除未使用引脚上的浪费电流消耗。
备注#10372-D:(ULP 4.1)在此项目中检测到未初始化的端口6。建议初始化所有未使用的端口,以消除未使用引脚上的浪费电流消耗。
备注#10372-D:(ULP 4.1)在此项目中检测到未初始化的端口7。建议初始化所有未使用的端口,以消除未使用引脚上的浪费电流消耗。
备注#10372-D:(ULP 4.1)在此项目中检测到未初始化的端口8。建议初始化所有未使用的端口,以消除未使用引脚上的浪费电流消耗。
备注#10372-D:(ULP 4.1)在此项目中检测到未初始化的端口9。建议初始化所有未使用的端口,以消除未使用引脚上的浪费电流消耗。
备注#10372-D:(ULP 4.1)在此项目中检测到未初始化的端口10。建议初始化所有未使用的端口,以消除未使用引脚上的浪费电流消耗。
完成构建目标:“00.static.global.const.array.of.int.out”
构建文件:“00.static.global.const.array.of.int.out”
调用:armhex实用程序
“/opt/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.2.LTS/bin/armhex”--memwidth=8--romwidth=8-o“00.static.global.const.array.of.ints.hex”“00.static.global.const.array.of.ints.out”
正在转换为扩展的Tektronix格式。。。
“00.static.global.const.array.of.ints.out”.intvecs==>.intvecs
“00.static.global.const.array.of.ints.out”.text==>.text
“00.static.global.const.array.of.ints.out”.cinit==>.cinit
完成构建:“00.static.global.const.array.of.int.out”
****建成****

一种方法是使用STM32 Nucleo-64(Nucleo-F303RE)为我工作。为了简化示例,我在重置处理程序中运行了代码

.syntax unified
.cpu cortex-m4

.fpu vfpv4

.thumb

.global vtable
.global reset_handler
.type vtable, %object
vtable:
    .word _estack
    .word reset_handler
.size vtable, .-vtable

/***********************************************************
* 'Array' declaration / initialization begins here
***********************************************************/
.type myarray, %object
myarray:
    .word   0x11111111
    .word   0x22222222
    .word   0x33333333
.size myarray, .-myarray
/***********************************************************
* 'Array' declaration / initialization ends here
***********************************************************/

.equ    myarraysize, 5  //the number of 'elements' in the 'array'.


.type reset_handler, %function
reset_handler:
  LDR  r0, =_estack
  MOV  sp, r0

    /******************************************************************
    *  START - code example using array
    /*****************************************************************/

    LDR  R1,=myarray  // this loads the location value itself (the 1st address),

    MOV  R2,#0        // R2 will keep a count to make sure we don't walk off
                      // end of array.

    LDR  R3,=myarrsize // R3 will be the equivalent of 'myarrsize'.

                       // R0 will hold our data (pretends we're using data).

main_loop:
    LDR R0,[R1]        // Load the data pointed to by R1 ('myarray') into R0.
    CMP R2,R3          // Are we at limit of array?
    BEQ main_loop      // If we are, we're done, so we'll just loop forever.
    ADD R2,#1          // Not done, keep going, keep count.
    ADD R1,#4          // Add 4 to register R1, so it points correctly to next
                       // address..
    B    main_loop     // Loop back.     

    /******************************************************************
    *  END - code example using array
    /*****************************************************************/


.size reset_handler, .-reset_handler

在C
const int somearr[]={1,2,3,4,5,6,7};
中,将数据放在
.rodata
段中

要存档相同的内容,您需要将表格放在本节中


我不知道代码编写器,但gnu汇编程序有
.section
指令

不清楚您的确切问题是什么/在哪里…是访问闪存I吗
#include "msp.h"

static const int somearr[] = { 1,2,3,4,5,6,7};

void main(void) {
    int i = somearr[0];//needed so compiler would not ignore declaration
}
**** Build of configuration Debug for project 00.static.global.const.array.of.ints ****

/opt/ti/ccsv8/utils/bin/gmake -k -j 2 all -O 

Building file: "../main.c"
Invoking: ARM Compiler
"/opt/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.2.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --include_path="/opt/ti/ccsv8/ccs_base/arm/include" --include_path="/opt/ti/ccsv8/ccs_base/arm/include/CMSIS" --include_path="/home/devchu/Development/ti.robotics/tirslk_maze_1_00_00/00.static.global.const.array.of.ints" --include_path="/opt/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.2.LTS/include" --advice:power=all --define=__MSP432P401R__ --define=ccs -g --gcc --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi --preproc_with_compile --preproc_dependency="main.d_raw"  "../main.c"
"../main.c", line 3: warning #179-D: variable "somearr" was declared but never referenced
Finished building: "../main.c"

Building target: "00.static.global.const.array.of.ints.out"
Invoking: ARM Linker
"/opt/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.2.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --advice:power=all --define=__MSP432P401R__ --define=ccs -g --gcc --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi -z -m"00.static.global.const.array.of.ints.map" --heap_size=1024 --stack_size=512 -i"/opt/ti/ccsv8/ccs_base/arm/include" -i"/opt/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.2.LTS/lib" -i"/opt/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.2.LTS/include" --reread_libs --diag_wrap=off --display_error_number --warn_sections --xml_link_info="00.static.global.const.array.of.ints_linkInfo.xml" --rom_model -o "00.static.global.const.array.of.ints.out" "./main.obj" "./startup_msp432p401r_ccs.obj" "./system_msp432p401r.obj" "../msp432p401r.cmd"  -llibc.a 
<Linking>
remark #10371-D: (ULP 1.1) Detected no uses of low power mode state changing instructions
remark #10372-D: (ULP 4.1) Detected uninitialized Port 1 in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port 2 in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port 3 in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port 4 in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port 5 in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port 6 in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port 7 in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port 8 in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port 9 in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port 10 in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
Finished building target: "00.static.global.const.array.of.ints.out"

Building files: "00.static.global.const.array.of.ints.out"
Invoking: ARM Hex Utility
"/opt/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.2.LTS/bin/armhex" --memwidth=8 --romwidth=8 -o "00.static.global.const.array.of.ints.hex"  "00.static.global.const.array.of.ints.out" 
Translating to Extended Tektronix format...
   "00.static.global.const.array.of.ints.out" .intvecs ==> .intvecs
   "00.static.global.const.array.of.ints.out" .text ==> .text
   "00.static.global.const.array.of.ints.out" .cinit ==> .cinit
Finished building: "00.static.global.const.array.of.ints.out"


**** Build Finished ****
.syntax unified
.cpu cortex-m4

.fpu vfpv4

.thumb

.global vtable
.global reset_handler
.type vtable, %object
vtable:
    .word _estack
    .word reset_handler
.size vtable, .-vtable

/***********************************************************
* 'Array' declaration / initialization begins here
***********************************************************/
.type myarray, %object
myarray:
    .word   0x11111111
    .word   0x22222222
    .word   0x33333333
.size myarray, .-myarray
/***********************************************************
* 'Array' declaration / initialization ends here
***********************************************************/

.equ    myarraysize, 5  //the number of 'elements' in the 'array'.


.type reset_handler, %function
reset_handler:
  LDR  r0, =_estack
  MOV  sp, r0

    /******************************************************************
    *  START - code example using array
    /*****************************************************************/

    LDR  R1,=myarray  // this loads the location value itself (the 1st address),

    MOV  R2,#0        // R2 will keep a count to make sure we don't walk off
                      // end of array.

    LDR  R3,=myarrsize // R3 will be the equivalent of 'myarrsize'.

                       // R0 will hold our data (pretends we're using data).

main_loop:
    LDR R0,[R1]        // Load the data pointed to by R1 ('myarray') into R0.
    CMP R2,R3          // Are we at limit of array?
    BEQ main_loop      // If we are, we're done, so we'll just loop forever.
    ADD R2,#1          // Not done, keep going, keep count.
    ADD R1,#4          // Add 4 to register R1, so it points correctly to next
                       // address..
    B    main_loop     // Loop back.     

    /******************************************************************
    *  END - code example using array
    /*****************************************************************/


.size reset_handler, .-reset_handler