This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C2000 汇编调用C编写的结构体

问题1, 如何在汇编中引用C的结构体。

例如 : 在c中定义  struct STRUCT_SETUP  {  char name [17] ;

                                                                           float min ;  

                                                                           float max ;  

                                                                           float def ; };

                                                             struct STRUCT_SETUP  parm1;

如何在汇编中实现    MOV    ACC, parm1.min   

问题2:如何在汇编中的结构体 常量 赋值

item .struct ; item structure definition

value .int ; value offset = 0

delta .int ; delta offset = 4

i_len .endstruct ; item size = 8

array .tag item 

array .usect ".econst", i_len*1 ; declare an array of K "items"

如何实现  定义好 array.value = 1;  array.delta = 2

  • 你的两个问题是同一个问题,

    调用结构体,你先要引用这个结构体:

    .ref _parm1

    当然还有在.asm中用以下指令include你的结构声明的.h

    .cdecls C,NOLIST, "xxxxx.h"

    然后 在程序里用

    MOVW DP #_parm1

    MOVL XAR1 @_parm1

    MOVL ACC, #0x0001

    MOVL *XAR1[0], ACC

    这样就把第一个成员赋值了,

    如果要赋值第二个可以是

    MOVL *XAR1[2], ACC

    以此类推。